Squashed spy refactor and new spy syntax
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.
This commit is contained in:
committed by
Colin O'Byrne and JR Boyens
parent
18c30566bd
commit
3847557bbc
@@ -31,7 +31,7 @@ describe("Clock", function() {
|
||||
it("returns an id for the delayed function", function() {
|
||||
var setTimeout = jasmine.createSpy('setTimeout'),
|
||||
scheduleId = 123,
|
||||
scheduleFunction = jasmine.createSpy('scheduleFunction').andReturn(scheduleId),
|
||||
scheduleFunction = jasmine.createSpy('scheduleFunction').and.callReturn(scheduleId),
|
||||
delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
|
||||
global = { setTimeout: setTimeout },
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
@@ -100,7 +100,7 @@ describe("Clock", function() {
|
||||
it("returns an id for the delayed function", function() {
|
||||
var setInterval = jasmine.createSpy('setInterval'),
|
||||
scheduleId = 123,
|
||||
scheduleFunction = jasmine.createSpy('scheduleFunction').andReturn(scheduleId),
|
||||
scheduleFunction = jasmine.createSpy('scheduleFunction').and.callReturn(scheduleId),
|
||||
delayedFunctionScheduler = {scheduleFunction: scheduleFunction},
|
||||
global = { setInterval: setInterval },
|
||||
delayedFn = jasmine.createSpy('delayedFn'),
|
||||
@@ -239,25 +239,25 @@ describe("Clock (acceptance)", function() {
|
||||
clock.tick(50);
|
||||
|
||||
expect(recurring1).toHaveBeenCalledWith('some', 'other', 'args');
|
||||
expect(recurring1.callCount).toBe(1);
|
||||
expect(recurring1.calls.count()).toBe(1);
|
||||
expect(delayedFn2).not.toHaveBeenCalled();
|
||||
expect(delayedFn3).not.toHaveBeenCalled();
|
||||
|
||||
clock.tick(50);
|
||||
|
||||
expect(recurring1.callCount).toBe(2);
|
||||
expect(recurring1.calls.count()).toBe(2);
|
||||
expect(delayedFn2).toHaveBeenCalled();
|
||||
expect(delayedFn3).not.toHaveBeenCalled();
|
||||
|
||||
clock.tick(100);
|
||||
|
||||
expect(recurring1.callCount).toBe(4);
|
||||
expect(recurring1.calls.count()).toBe(4);
|
||||
expect(delayedFn3).toHaveBeenCalled();
|
||||
|
||||
clock.clearInterval(intervalId);
|
||||
clock.tick(50);
|
||||
|
||||
expect(recurring1.callCount).toBe(4);
|
||||
expect(recurring1.calls.count()).toBe(4);
|
||||
});
|
||||
|
||||
it("can clear a previously set timeout", function() {
|
||||
|
||||
Reference in New Issue
Block a user