Skip to content

Commit

Permalink
Merge pull request #724 from meeber/issue-718
Browse files Browse the repository at this point in the history
Fix chai.use as ES6 named export
  • Loading branch information
lucasfcosta committed Jun 9, 2016
2 parents 89231de + a1c5ff7 commit fd2cc2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/chai.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ var util = require('./chai/utils');

exports.use = function (fn) {
if (!~used.indexOf(fn)) {
fn(this, util);
fn(exports, util);
used.push(fn);
}

return this;
return exports;
};

/*!
Expand Down
16 changes: 16 additions & 0 deletions test/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,20 @@ describe('plugins', function () {
chai.use(plugin);
}).to.not.throw();
});

it('.use detached from chai object', function () {
function anotherPlugin (chai) {
Object.defineProperty(chai.Assertion.prototype, 'moreTesting', {
get: function () {
return 'more success';
}
});
}

var use = chai.use;
use(anotherPlugin);

var expect = chai.expect;
expect(expect('').moreTesting).to.equal('more success');
});
});

0 comments on commit fd2cc2b

Please sign in to comment.