DEV: refactors textarea-selection helper to prevent leaking (#7709)

DEV: refactors textarea-selection helper to prevent leaking (#7709)

diff --git a/.eslintrc b/.eslintrc
index 75fcbf0..e5a36ab 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -59,8 +59,6 @@
     "selectKitSelectRowByIndex": true,
     "selectKitSelectRowByName": true,
     "selectKitSelectRowByValue": true,
-    "setTextareaSelection": true,
-    "getTextareaSelection": true,
     "sinon": true,
     "test": true,
     "triggerEvent": true,
diff --git a/test/javascripts/components/d-editor-test.js.es6 b/test/javascripts/components/d-editor-test.js.es6
index edb1a53..3ab5538 100644
--- a/test/javascripts/components/d-editor-test.js.es6
+++ b/test/javascripts/components/d-editor-test.js.es6
@@ -1,6 +1,10 @@
 import componentTest from "helpers/component-test";
 import { withPluginApi } from "discourse/lib/plugin-api";
 import formatTextWithSelection from "helpers/d-editor-helper";
+import {
+  setTextareaSelection,
+  getTextareaSelection
+} from "helpers/textarea-selection-helper";
 
 moduleForComponent("d-editor", { integration: true });
 
diff --git a/test/javascripts/helpers/textarea-selection-helper.js.es6 b/test/javascripts/helpers/textarea-selection-helper.js.es6
new file mode 100644
index 0000000..1f914d7
--- /dev/null
+++ b/test/javascripts/helpers/textarea-selection-helper.js.es6
@@ -0,0 +1,10 @@
+export function setTextareaSelection(textarea, selectionStart, selectionEnd) {
+  textarea.selectionStart = selectionStart;
+  textarea.selectionEnd = selectionEnd;
+}
+
+export function getTextareaSelection(textarea) {
+  const start = textarea.selectionStart;
+  const end = textarea.selectionEnd;
+  return [start, end - start];
+}
diff --git a/test/javascripts/helpers/textarea-selection.js b/test/javascripts/helpers/textarea-selection.js
deleted file mode 100644
index c406928..0000000
--- a/test/javascripts/helpers/textarea-selection.js
+++ /dev/null
@@ -1,15 +0,0 @@
-Ember.Test.registerHelper("setTextareaSelection", function(
-  app,
-  textarea,
-  selectionStart,
-  selectionEnd
-) {
-  textarea.selectionStart = selectionStart;
-  textarea.selectionEnd = selectionEnd;
-});
-
-Ember.Test.registerHelper("getTextareaSelection", function(app, textarea) {
-  var start = textarea.selectionStart;
-  var end = textarea.selectionEnd;
-  return [start, end - start];
-});
diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.js
index 1fe03be..1d8a8aa 100644
--- a/test/javascripts/test_helper.js
+++ b/test/javascripts/test_helper.js
@@ -30,7 +30,6 @@
 //= require sinon/pkg/sinon
 
 //= require helpers/assertions
-//= require helpers/textarea-selection
 //= require helpers/select-kit-helper
 
 //= require helpers/qunit-helpers

GitHub sha: de013262

1 Like