-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathjasmine.js
More file actions
32 lines (31 loc) · 1.16 KB
/
jasmine.js
File metadata and controls
32 lines (31 loc) · 1.16 KB
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
/**
* Custom matchers implemented as part of the migration from Karma to Web Test
* Runner. Should be removed and usage replaced with chai assertions.
* @type {Chai.ChaiPlugin}
*/
export const registerJasmineMatchers = (chai, utils) => {
const matchers = {
toHaveSize(size) {
const value = utils.flag(this, 'object');
chai.expect(value).to.have.length(size);
},
toBeFalse() {
const value = utils.flag(this, 'object');
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
chai.expect(value).to.be.false;
},
toBeTrue() {
const value = utils.flag(this, 'object');
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
chai.expect(value).to.be.true;
},
toHaveBeenCalledOnceWith(...args) {
const spy = utils.flag(this, 'object');
chai.expect(spy.calls).to.have.length(1);
chai.expect(spy.calls[0]).to.deep.equal(args);
},
};
for (const [name, impl] of Object.entries(matchers)) {
utils.addMethod(chai.Assertion.prototype, name, impl);
}
};