Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Commit

Permalink
Merge pull request #21 from alexlafroscia/support-testdouble-chai
Browse files Browse the repository at this point in the history
Add support for testdouble-chai
  • Loading branch information
Turbo87 authored Dec 20, 2016
2 parents 754367e + ffe566f commit bdd1e2c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
24 changes: 22 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,20 @@ var sinonPlugin = {
path: 'sinon-chai.js',
};

var testdoublePlugin = {
name: 'testdouble-chai',
constraint: '^0.5.0',
path: 'testdouble-chai.js',
supportFile: 'bootstrap-td-chai.js'
};

var supportedPlugins = [
jqueryPlugin,
domPlugin,
asPromisedPlugin,
asPromisedPlugin6,
sinonPlugin
sinonPlugin,
testdoublePlugin
];

module.exports = {
Expand All @@ -79,6 +87,14 @@ module.exports = {
if (jqueryPluginIndex !== -1 && domPluginIndex !== -1) {
this.plugins.splice(domPluginIndex, 1);
}

// ensure that `sinon-chai` and `testdouble-chai` aren't both enabled,
// since they use the same API
var sinonIndex = this.plugins.indexOf(sinonPlugin);
var tdIndex = this.plugins.indexOf(testdoublePlugin);
if (sinonIndex !== -1 && tdIndex !== -1) {
this.plugins.splice(tdIndex, 1);
}
},

included: function included(app) {
Expand All @@ -93,6 +109,10 @@ module.exports = {

this.plugins.forEach(function(plugin) {
app.import('vendor/chai/' + plugin.path, { type: 'test' });

if (plugin.supportFile) {
app.import('vendor/chai-plugin-support/' + plugin.supportFile, { type: 'test' });
}
});
},

Expand Down Expand Up @@ -133,4 +153,4 @@ module.exports = {
annotation: 'ember-cli-chai: treeForVendor'
});
}
};
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"ember-sinon": "0.5.1",
"ember-welcome-page": "^1.0.3",
"loader.js": "^4.0.10",
"sinon-chai": "^2.0.0"
"sinon-chai": "^2.0.0",
"testdouble-chai": "^0.5.0"
},
"engines": {
"node": ">= 0.12.0"
Expand Down
3 changes: 3 additions & 0 deletions vendor/chai-plugin-support/bootstrap-td-chai.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(function() {
chai.use(tdChai(td));
})();

0 comments on commit bdd1e2c

Please sign in to comment.