diff --git a/.eslintrc b/.eslintrc index 0f2d2c87436..96a41ba6b69 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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" } diff --git a/test/javascripts/components/d-editor-test.js.es6 b/test/javascripts/components/d-editor-test.js.es6 index 26803f99456..2da16a65d60 100644 --- a/test/javascripts/components/d-editor-test.js.es6 +++ b/test/javascripts/components/d-editor-test.js.es6 @@ -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); diff --git a/test/javascripts/helpers/set-textarea-selection.js b/test/javascripts/helpers/set-textarea-selection.js new file mode 100644 index 00000000000..b6f219e0929 --- /dev/null +++ b/test/javascripts/helpers/set-textarea-selection.js @@ -0,0 +1,9 @@ +Ember.Test.registerHelper("setTextareaSelection", function( + app, + textarea, + selectionStart, + selectionEnd +) { + textarea.selectionStart = selectionStart; + textarea.selectionEnd = selectionEnd; +}); diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.js index 67a429395e7..bf920e75571 100644 --- a/test/javascripts/test_helper.js +++ b/test/javascripts/test_helper.js @@ -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