Skip to content

Commit

Permalink
test(TzDate): fix test in Australia
Browse files Browse the repository at this point in the history
Probably due to implementation differences in browsers for pre-DST period (see
angular#5017 and especially
angular#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 angular#14272
  • Loading branch information
gkalpak committed Mar 21, 2016
1 parent 7e5e66f commit 8e827c3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/ngMock/angular-mocksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ describe('ngMock', function() {


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

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

//0 in +3h
var t2 = new angular.mock.TzDate(3, 0);
expect(t2.toLocaleDateString()).toMatch('1969');
// millenium in +0h
var t1 = new angular.mock.TzDate(0, millenium);
expect(t1.toLocaleDateString()).toMatch('2000');

// millenium in +3h
var t2 = new angular.mock.TzDate(3, millenium);
expect(t2.toLocaleDateString()).toMatch('1999');
});


Expand Down

0 comments on commit 8e827c3

Please sign in to comment.