DEV: setTextareaSelection helper (#7609)
This commit is contained in:
parent
42c82d544e
commit
669bfaba30
|
@ -5,7 +5,7 @@
|
|||
"es6": true,
|
||||
"jasmine": true,
|
||||
"mocha": true,
|
||||
"node": true,
|
||||
"node": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 7,
|
||||
|
@ -57,6 +57,7 @@
|
|||
"selectKitSelectRowByIndex": true,
|
||||
"selectKitSelectRowByName": true,
|
||||
"selectKitSelectRowByValue": true,
|
||||
"setTextareaSelection": true,
|
||||
"sinon": true,
|
||||
"test": true,
|
||||
"triggerEvent": true,
|
||||
|
@ -99,7 +100,7 @@
|
|||
"semi": 2,
|
||||
"strict": 0,
|
||||
"valid-typeof": 2,
|
||||
"wrap-iife": [2, "inside"],
|
||||
"wrap-iife": [2, "inside"]
|
||||
},
|
||||
"parser": "babel-eslint"
|
||||
}
|
||||
|
|
|
@ -777,11 +777,6 @@ composerTestCase("replace-text event for composer", async function(assert) {
|
|||
}
|
||||
];
|
||||
|
||||
function setSelection(textarea, [start, len]) {
|
||||
textarea.selectionStart = start;
|
||||
textarea.selectionEnd = start + len;
|
||||
}
|
||||
|
||||
function getSelection(textarea) {
|
||||
const start = textarea.selectionStart;
|
||||
const end = textarea.selectionEnd;
|
||||
|
@ -802,13 +797,14 @@ composerTestCase("replace-text event for composer", async function(assert) {
|
|||
assert.ok(document.activeElement === textarea);
|
||||
assert.ok(textarea.value === BEFORE);
|
||||
|
||||
setSelection(textarea, CASE.before);
|
||||
const [start, len] = CASE.before;
|
||||
setTextareaSelection(textarea, start, start + len);
|
||||
|
||||
assert.ok(document.activeElement === textarea);
|
||||
|
||||
this.container
|
||||
.lookup("app-events:main")
|
||||
.trigger("composer:replace-text", "green", "yellow", {forceFocus: true});
|
||||
.trigger("composer:replace-text", "green", "yellow", { forceFocus: true });
|
||||
|
||||
assert.ok(document.activeElement === textarea);
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
Ember.Test.registerHelper("setTextareaSelection", function(
|
||||
app,
|
||||
textarea,
|
||||
selectionStart,
|
||||
selectionEnd
|
||||
) {
|
||||
textarea.selectionStart = selectionStart;
|
||||
textarea.selectionEnd = selectionEnd;
|
||||
});
|
|
@ -30,6 +30,7 @@
|
|||
//= require sinon/pkg/sinon
|
||||
|
||||
//= require helpers/assertions
|
||||
//= require helpers/set-textarea-selection
|
||||
//= require helpers/select-kit-helper
|
||||
//= require helpers/d-editor-helper
|
||||
|
||||
|
|
Loading…
Reference in New Issue