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.
14 lines
317 B
JavaScript
14 lines
317 B
JavaScript
describe("Timer", function() {
|
|
it("reports the time elapsed", function() {
|
|
var fakeNow = jasmine.createSpy('fake Date.now'),
|
|
timer = new j$.Timer({now: fakeNow});
|
|
|
|
fakeNow.and.callReturn(100);
|
|
timer.start();
|
|
|
|
fakeNow.and.callReturn(200);
|
|
|
|
expect(timer.elapsed()).toEqual(100);
|
|
});
|
|
});
|