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

Add support for testdouble-chai #21

Merged
merged 3 commits into from
Dec 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about the releases below 0.5.0? they don't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK they all "work" but 0.5.0 removed testdouble as a peer dependency, which caused some issues with ember-cli-testdouble-chai because testdouble was provided by ember-cli-testdouble.

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));
})();