2013-09-17 21:22:36 +00:00
|
|
|
describe('plugins', function () {
|
2012-02-07 21:09:38 +00:00
|
|
|
|
|
|
|
function plugin (chai) {
|
2012-04-29 06:32:55 +00:00
|
|
|
if (chai.Assertion.prototype.testing) return;
|
|
|
|
|
2012-02-07 21:09:38 +00:00
|
|
|
Object.defineProperty(chai.Assertion.prototype, 'testing', {
|
|
|
|
get: function () {
|
|
|
|
return 'successful';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-09-17 21:22:36 +00:00
|
|
|
it('basic usage', function () {
|
2012-02-07 21:09:38 +00:00
|
|
|
chai.use(plugin);
|
|
|
|
var expect = chai.expect;
|
|
|
|
expect(expect('').testing).to.equal('successful');
|
|
|
|
});
|
|
|
|
|
2013-09-17 21:22:36 +00:00
|
|
|
it('double plugin', function () {
|
2012-02-07 21:09:38 +00:00
|
|
|
chai.expect(function () {
|
|
|
|
chai.use(plugin);
|
|
|
|
}).to.not.throw();
|
|
|
|
});
|
2016-06-09 21:49:18 +00:00
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
2012-02-07 21:09:38 +00:00
|
|
|
});
|