From 289c8313d191e9363b956ea7495de71a85a1a191 Mon Sep 17 00:00:00 2001 From: Sheel Choksi Date: Sun, 9 Feb 2014 12:04:14 -0800 Subject: [PATCH] Short spec to document why we close over Date and ensure cross-browser compatibility [closes #506] --- spec/core/TimerSpec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/core/TimerSpec.js b/spec/core/TimerSpec.js index 62312c47..41e28148 100644 --- a/spec/core/TimerSpec.js +++ b/spec/core/TimerSpec.js @@ -10,4 +10,22 @@ describe("Timer", function() { expect(timer.elapsed()).toEqual(100); }); + + describe("when date is stubbed, perhaps by other testing helpers", function() { + var origDate = Date; + beforeEach(function() { + Date = jasmine.createSpy('date spy'); + }); + + afterEach(function() { + Date = origDate; + }); + + it("does not throw even though Date was taken away", function() { + var timer = new j$.Timer(); + + expect(timer.start).not.toThrow(); + expect(timer.elapsed()).toEqual(jasmine.any(Number)); + }); + }); });