chai/test/plugins.js

41 lines
918 B
JavaScript
Raw Normal View History

describe('plugins', function () {
2012-02-07 21:09:38 +00:00
function plugin (chai) {
if (chai.Assertion.prototype.testing) return;
2012-02-07 21:09:38 +00:00
Object.defineProperty(chai.Assertion.prototype, 'testing', {
get: function () {
return 'successful';
}
});
}
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');
});
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
});