Jasmine spies now have a 'and' property which allows the user to change the spy's execution strategy-- such as '.and.callReturn(4)' and a 'calls' property which allows inspection of the calls a spy has received. * This is a breaking change * There is a CallTracker that keeps track of all calls and arguments and a SpyStrategy which determines what the spy should do when it is called.
29 lines
816 B
JavaScript
29 lines
816 B
JavaScript
describe("toEqual", function() {
|
|
it("delegates to equals function", function() {
|
|
var util = {
|
|
equals: jasmine.createSpy('delegated-equals').and.callReturn(true)
|
|
},
|
|
matcher = j$.matchers.toEqual(util),
|
|
result;
|
|
|
|
result = matcher.compare(1, 1);
|
|
|
|
expect(util.equals).toHaveBeenCalledWith(1, 1, []);
|
|
expect(result.pass).toBe(true);
|
|
});
|
|
|
|
it("delegates custom equality testers, if present", function() {
|
|
var util = {
|
|
equals: jasmine.createSpy('delegated-equals').and.callReturn(true)
|
|
},
|
|
customEqualityTesters = ['a', 'b'],
|
|
matcher = j$.matchers.toEqual(util, customEqualityTesters),
|
|
result;
|
|
|
|
result = matcher.compare(1, 1);
|
|
|
|
expect(util.equals).toHaveBeenCalledWith(1, 1, ['a', 'b']);
|
|
expect(result.pass).toBe(true);
|
|
});
|
|
});
|