diff options
| author | Brett Porter | 2014-03-18 15:36:00 +1100 |
|---|---|---|
| committer | Igor Minar | 2014-03-18 21:31:20 -0700 |
| commit | d4ac25496aaace2b85aa9f5e5232e5eabeb40c63 (patch) | |
| tree | b26ba36a9a8dd5ea17a6236a10bae326bbf9ced3 | |
| parent | e84da2283c4e195be557f7b06c8783fe502acbbb (diff) | |
| download | angular.js-d4ac25496aaace2b85aa9f5e5232e5eabeb40c63.tar.bz2 | |
test(ngMock): workaround issue with negative timestamps
In some specific timezones and operating systems, it seems that
getTimezoneOffset() can return an incorrect value for negative timestamps, as
described in #5017. While this isn't something easily fixed in the mock code,
the tests can avoid that particular timeframe by using a positive timestamp.
Closes #5017
Closes #6730
| -rw-r--r-- | test/ngMock/angular-mocksSpec.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index c2b6108d..b78e9bbf 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -52,16 +52,19 @@ describe('ngMock', function() { it('should fake getHours method', function() { - //0 in -3h - var t0 = new angular.mock.TzDate(-3, 0); + // avoid going negative due to #5017, so use Jan 2, 1970 00:00 UTC + var jan2 = 24 * 60 * 60 * 1000; + + //0:00 in -3h + var t0 = new angular.mock.TzDate(-3, jan2); expect(t0.getHours()).toBe(3); - //0 in +0h - var t1 = new angular.mock.TzDate(0, 0); + //0:00 in +0h + var t1 = new angular.mock.TzDate(0, jan2); expect(t1.getHours()).toBe(0); - //0 in +3h - var t2 = new angular.mock.TzDate(3, 0); + //0:00 in +3h + var t2 = new angular.mock.TzDate(3, jan2); expect(t2.getHours()).toMatch(21); }); |
