From 8210cb310e2e5e65ca45822355ab809dccec1324 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Tue, 17 Jan 2017 11:44:57 +0100 Subject: [PATCH] Replace initializer with IIFE in the vendor tree --- README.md | 10 ---------- addon/initializers/ember-test-selectors.js | 16 ---------------- app/.eslintrc.js | 9 --------- app/initializers/ember-test-selectors.js | 1 - blueprints/.eslintrc.js | 11 ----------- .../files/tests/helpers/test-selectors.js | 11 ----------- blueprints/index.js | 17 ----------------- index.js | 11 ++++------- vendor/ember-test-selectors/patch-component.js | 15 +++++++++++++++ 9 files changed, 19 insertions(+), 82 deletions(-) delete mode 100644 addon/initializers/ember-test-selectors.js delete mode 100644 app/.eslintrc.js delete mode 100644 app/initializers/ember-test-selectors.js delete mode 100644 blueprints/.eslintrc.js delete mode 100644 blueprints/files/tests/helpers/test-selectors.js delete mode 100644 blueprints/index.js create mode 100644 vendor/ember-test-selectors/patch-component.js diff --git a/README.md b/README.md index 0e5b72cd..e527aa09 100644 --- a/README.md +++ b/README.md @@ -37,16 +37,6 @@ Installation ember install ember-test-selectors ``` -When you install the addon, it should automatically generate a helper located at -`tests/helpers/test-selectors.js` as well as add an import to load that helper -in `tests/test-helper.js`. This sets up the component `data-test-*` auto-binding -for integration tests. - -You can do this manually as well: - -``` -$ ember generate ember-test-selectors -``` Usage ------------------------------------------------------------------------------ diff --git a/addon/initializers/ember-test-selectors.js b/addon/initializers/ember-test-selectors.js deleted file mode 100644 index a6487301..00000000 --- a/addon/initializers/ember-test-selectors.js +++ /dev/null @@ -1,16 +0,0 @@ -import Ember from 'ember'; -import bindDataTestAttributes from '../utils/bind-data-test-attributes'; - -function initialize(/* application */) { - Ember.Component.reopen({ - init() { - this._super(...arguments); - bindDataTestAttributes(this); - } - }); -} - -export default { - name: 'ember-test-selectors', - initialize -}; diff --git a/app/.eslintrc.js b/app/.eslintrc.js deleted file mode 100644 index 033f9d64..00000000 --- a/app/.eslintrc.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - parserOptions: { - ecmaVersion: 6, - sourceType: 'module', - }, - env: { - node: true - }, -}; diff --git a/app/initializers/ember-test-selectors.js b/app/initializers/ember-test-selectors.js deleted file mode 100644 index 9487acb8..00000000 --- a/app/initializers/ember-test-selectors.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'ember-test-selectors/initializers/ember-test-selectors'; diff --git a/blueprints/.eslintrc.js b/blueprints/.eslintrc.js deleted file mode 100644 index af760d3a..00000000 --- a/blueprints/.eslintrc.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - parserOptions: { - ecmaVersion: 6, - sourceType: 'module' - }, - env: { - node: null, - browser: true, - embertest: true, - }, -}; diff --git a/blueprints/files/tests/helpers/test-selectors.js b/blueprints/files/tests/helpers/test-selectors.js deleted file mode 100644 index c31dd3df..00000000 --- a/blueprints/files/tests/helpers/test-selectors.js +++ /dev/null @@ -1,11 +0,0 @@ -import Ember from 'ember'; -import bindDataTestAttributes from 'ember-test-selectors/utils/bind-data-test-attributes'; - -const { Component } = Ember; - -Component.reopen({ - init() { - this._super(...arguments); - bindDataTestAttributes(this); - } -}); diff --git a/blueprints/index.js b/blueprints/index.js deleted file mode 100644 index 118a2f43..00000000 --- a/blueprints/index.js +++ /dev/null @@ -1,17 +0,0 @@ -var EOL = require('os').EOL; - -module.exports = { - description: 'Generates ember-test-selectors test helper', - - afterInstall: function() { - var TEST_HELPER_PATH = 'tests/test-helper.js'; - var IMPORT_STATEMENT = EOL + "import './helpers/test-selectors';"; - var INSERT_AFTER = "import resolver from './helpers/resolver';"; - - return this.insertIntoFile(TEST_HELPER_PATH, IMPORT_STATEMENT, { - after: INSERT_AFTER - }); - }, - - normalizeEntityName: function() {} -}; diff --git a/index.js b/index.js index 5f13cb53..4fe22377 100644 --- a/index.js +++ b/index.js @@ -53,19 +53,16 @@ module.exports = { this._registeredWithBabel = true; } - }, - treeForAddon: function() { - // remove our "addon" folder from the build if we're stripping test selectors if (!this._stripTestSelectors) { - return this._super.treeForAddon.apply(this, arguments); + app.import('vendor/ember-test-selectors/patch-component.js'); } }, - treeForApp: function() { - // remove our "app" folder from the build if we're stripping test selectors + treeForAddon: function() { + // remove our "addon" folder from the build if we're stripping test selectors if (!this._stripTestSelectors) { - return this._super.treeForApp.apply(this, arguments); + return this._super.treeForAddon.apply(this, arguments); } }, diff --git a/vendor/ember-test-selectors/patch-component.js b/vendor/ember-test-selectors/patch-component.js new file mode 100644 index 00000000..ba2c0a69 --- /dev/null +++ b/vendor/ember-test-selectors/patch-component.js @@ -0,0 +1,15 @@ +/* global Ember */ + +(function() { + var bindDataTestAttributes; + + Ember.Component.reopen({ + init: function() { + this._super.apply(this, arguments); + if (!bindDataTestAttributes) { + bindDataTestAttributes = require('ember-test-selectors/utils/bind-data-test-attributes')['default']; + } + bindDataTestAttributes(this); + } + }); +})();