From bcf0b2807b638eaad8893473eee167bce1369034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pa=CC=88rsson?= Date: Wed, 5 Aug 2015 09:47:32 +0200 Subject: [PATCH] Add test for Jasmine's jasmine.clock().mockDate(baseTime) --- jasmine/jasmine-tests.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index d5eb228c95..9f57219b84 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -721,6 +721,17 @@ describe("Manually ticking the Jasmine Clock", function () { jasmine.clock().tick(50); expect(timerCallback.calls.count()).toEqual(2); }); + + describe("Mocking the Date object", function(){ + it("mocks the Date object and sets it to a given time", function() { + var baseTime = new Date(2013, 9, 23); + + jasmine.clock().mockDate(baseTime); + + jasmine.clock().tick(50); + expect(new Date().getTime()).toEqual(baseTime.getTime() + 50); + }); + }); }); describe("Asynchronous specs", function () {