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.
25 lines
869 B
JavaScript
25 lines
869 B
JavaScript
describe("toContain", function() {
|
|
it("delegates to j$.matchersUtil.contains", function() {
|
|
var util = {
|
|
contains: jasmine.createSpy('delegated-contains').and.callReturn(true)
|
|
},
|
|
matcher = j$.matchers.toContain(util);
|
|
|
|
result = matcher.compare("ABC", "B");
|
|
expect(util.contains).toHaveBeenCalledWith("ABC", "B", []);
|
|
expect(result.pass).toBe(true);
|
|
});
|
|
|
|
it("delegates to j$.matchersUtil.contains, passing in equality testers if present", function() {
|
|
var util = {
|
|
contains: jasmine.createSpy('delegated-contains').and.callReturn(true)
|
|
},
|
|
customEqualityTesters = ['a', 'b'],
|
|
matcher = j$.matchers.toContain(util, customEqualityTesters);
|
|
|
|
result = matcher.compare("ABC", "B");
|
|
expect(util.contains).toHaveBeenCalledWith("ABC", "B", ['a', 'b']);
|
|
expect(result.pass).toBe(true);
|
|
});
|
|
});
|