forked from jasmine-sinon/jasmine-sinon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverwritten-jasmine-matchers.spec.js
36 lines (33 loc) · 1.13 KB
/
overwritten-jasmine-matchers.spec.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
if (typeof require === 'function' && typeof module === 'object') {
var sinon = require('sinon');
var jasmineSinon = require('../lib/jasmine-sinon.js');
}
describe('jasmine matchers gracefully overridden', function() {
beforeEach(function() {
this.methodVal = 'no';
this.api = {
myMethod: function(val) {
this.methodVal = val;
}
};
spyOn(this.api, 'myMethod').and.callThrough();
});
describe('toHaveBeenCalled', function() {
it('should work for jasmine spy', function() {
expect(this.methodVal).toEqual('no');
expect(this.api.myMethod).not.toHaveBeenCalled();
this.api.myMethod.call(this, 'yes');
expect(this.methodVal).toEqual('yes');
expect(this.api.myMethod).toHaveBeenCalled();
});
});
describe('toHaveBeenCalledWith', function() {
it('should work for jasmine spy', function() {
expect(this.methodVal).toEqual('no');
expect(this.api.myMethod).not.toHaveBeenCalledWith('yes');
this.api.myMethod.call(this, 'yes');
expect(this.methodVal).toEqual('yes');
expect(this.api.myMethod).toHaveBeenCalledWith('yes');
});
});
});