Skip to content

Commit

Permalink
Improve browser support
Browse files Browse the repository at this point in the history
  • Loading branch information
vesln committed Dec 13, 2013
1 parent 38c0383 commit 2e3a783
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
* External dependencies.
*/

var chai = global.chai || require('chai');
var root = this;

var chai = typeof root['chai'] === 'undefined'
? require('chai')
: root['chai'];

/**
* Chai.js plugin.
Expand All @@ -14,15 +18,16 @@ var chai = global.chai || require('chai');
* - diff: boolean show diff
*
* @param {Object} hydro
* @param {Object} util
* @api public
*/

module.exports = function(hydro) {
module.exports = function(hydro, util) {
var opts = hydro.get('chai') || {};
var styles = !Array.isArray(opts.styles) ? [opts.styles] : opts.styles;
var styles = util.toArray(opts.styles);

for (var i = 0, len = styles.length; i < len; i++) {
switch (styles[i]) {
util.forEach(styles, function(style) {
switch (style) {
case 'expect':
hydro.set('globals', 'expect', chai.expect);
break;
Expand All @@ -33,7 +38,7 @@ module.exports = function(hydro) {
hydro.set('globals', 'assert', chai.assert);
break;
}
}
});

if (opts.hasOwnProperty('stack')) {
chai.Assertion.includeStack = opts.stack;
Expand Down

0 comments on commit 2e3a783

Please sign in to comment.