Skip to content

Commit

Permalink
Merge pull request #1 from hydrojs/load
Browse files Browse the repository at this point in the history
enable passing a reference to chai
  • Loading branch information
jkroso committed Dec 29, 2013
2 parents 2e85c86 + 45c7018 commit db5b5f7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var root = typeof window === 'undefined' ? global : window;
*
* Options:
*
* - chai: object/string a reference to chai
* - styles: array/string should, expect, assert
* - stack: boolean include stack
* - diff: boolean show diff
Expand All @@ -26,8 +27,8 @@ var root = typeof window === 'undefined' ? global : window;
*/

module.exports = function(hydro, util) {
var chai = loa('chai');
var opts = hydro.get('chai') || {};
var chai = loa(opts.chai || 'chai');
var styles = util.toArray(opts.styles);
var plugin = null;

Expand All @@ -36,15 +37,13 @@ module.exports = function(hydro, util) {
util.forEach(styles, function(style) {
switch (style) {
case 'expect':
hydro.set('globals', 'expect', chai.expect);
case 'assert':
hydro.set('globals', style, chai[style]);
break;
case 'should':
var should = chai.Should();
if (!root.should) hydro.set('globals', 'should', should);
break;
case 'assert':
hydro.set('globals', 'assert', chai.assert);
break;
}
});

Expand Down

0 comments on commit db5b5f7

Please sign in to comment.