Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 48a256d

Browse files
committed
test(TzDate): fix test in Australia
Probably due to implementation differences in browsers for pre-DST period (see #5017 and especially #5017 (comment) for context), some `TzDate` tests had different behavior on different Timezones/Regions (e.g. failed in Australia, which started to observe DST in 1971). Since the used year (`1970`) didn't have any particular significance, this commit fixes the issue by using a year that is more consistently handled by browsers (`2000`). Fixes #14272 Closes #14285
1 parent 0579430 commit 48a256d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

test/ngMock/angular-mocksSpec.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,19 @@ describe('ngMock', function() {
2626

2727

2828
it('should fake getLocalDateString method', function() {
29-
//0 in -3h
30-
var t0 = new angular.mock.TzDate(-3, 0);
31-
expect(t0.toLocaleDateString()).toMatch('1970');
29+
var millenium = new Date('2000').getTime();
3230

33-
//0 in +0h
34-
var t1 = new angular.mock.TzDate(0, 0);
35-
expect(t1.toLocaleDateString()).toMatch('1970');
31+
// millenium in -3h
32+
var t0 = new angular.mock.TzDate(-3, millenium);
33+
expect(t0.toLocaleDateString()).toMatch('2000');
3634

37-
//0 in +3h
38-
var t2 = new angular.mock.TzDate(3, 0);
39-
expect(t2.toLocaleDateString()).toMatch('1969');
35+
// millenium in +0h
36+
var t1 = new angular.mock.TzDate(0, millenium);
37+
expect(t1.toLocaleDateString()).toMatch('2000');
38+
39+
// millenium in +3h
40+
var t2 = new angular.mock.TzDate(3, millenium);
41+
expect(t2.toLocaleDateString()).toMatch('1999');
4042
});
4143

4244

0 commit comments

Comments
 (0)