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

test(ngMock): workaround issue with negative timestamps #6730

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions test/ngMock/angular-mocksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down