-
-
Notifications
You must be signed in to change notification settings - Fork 692
/
plugins.js
42 lines (34 loc) · 956 Bytes
/
plugins.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import * as chai from '../index.js';
describe('plugins', function () {
function plugin (chai) {
if (chai.Assertion.prototype.testing) return;
Object.defineProperty(chai.Assertion.prototype, 'testing', {
get: function () {
return 'successful';
}
});
}
it('basic usage', function () {
chai.use(plugin);
var expect = chai.expect;
expect(expect('').testing).to.equal('successful');
});
it('double plugin', function () {
chai.expect(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');
});
});