Skip to content

Commit

Permalink
Guard existing ember-qunit < 5.0.0-beta.1 behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Oct 21, 2020
1 parent 325be7c commit 3ab10c6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
44 changes: 31 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,50 @@ const MergeTrees = require('broccoli-merge-trees');
module.exports = {
name: 'qunit-dom',

included() {
this._super.included.apply(this, arguments);
init() {
this._super.init.apply(this, arguments);

const VersionChecker = require('ember-cli-version-checker');
const checker = new VersionChecker(this.project);
this._supportOlderEmberQUnit = !checker.for('ember-qunit').gte('5.0.0-alpha.1');
},

included() {
this._super.included.apply(this, arguments);

if (!checker.for('ember-qunit').gte('5.0.0-alpha.1')) {
if (this._supportOlderEmberQUnit) {
this.import('vendor/qunit-dom.js', { type: 'test' });
this.import('vendor/overwrite-qunit-dom-root-element.js', { type: 'test' });
}
},

treeForVendor(vendorTree) {
let qunitPluginTree = new Funnel(`${__dirname}/dist`, {
files: ['qunit-dom.js', 'qunit-dom.js.map'],
});
if (this._supportOlderEmberQUnit) {
let qunitPluginTree = new Funnel(`${__dirname}/dist`, {
files: ['qunit-dom.js', 'qunit-dom.js.map'],
});

return new MergeTrees([vendorTree, qunitPluginTree]);
return new MergeTrees([vendorTree, qunitPluginTree]);
}
},

treeForAddonTestSupport() {
return new Funnel(`${__dirname}/vendor`, {
files: ['dummy-module.js'],
getDestinationPath() {
return 'qunit-dom/index.js';
},
});
if (this._supportOlderEmberQUnit) {
return new Funnel(`${__dirname}/vendor`, {
files: ['dummy-module.js'],
getDestinationPath() {
return 'qunit-dom/index.js';
},
});
} else {
let scopedInputTree = new Funnel(`${__dirname}/dist/addon-test-support`, {
destDir: 'qunit-dom',
});

return this.preprocessJs(scopedInputTree, '/', this.name, {
annotation: `qunit-dom - treeForAddonTestSupport`,
registry: this.registry,
});
}
},
};
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const esBundle = {
plugins: [typescript(typescriptConfiguration)],

output: {
file: 'dist/qunit-dom.es.js',
file: 'dist/addon-test-support/index.js',
format: 'es',
sourcemap: true,
},
Expand Down

0 comments on commit 3ab10c6

Please sign in to comment.