Skip to content

Commit

Permalink
Default behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
schickling committed Sep 26, 2013
1 parent b2fa2d0 commit 66fb64f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/timemachine.js
Expand Up @@ -23,8 +23,10 @@
apply: function () {
var self = this;
window.Date = function () {
if (arguments.length) {

if (arguments.length === 1) {
return new WindowDate(arguments[0]);
} else if (arguments.length === 7) {
return new WindowDate(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]);
} else {
return new WindowDate(self.dateString);
}
Expand Down
13 changes: 13 additions & 0 deletions test/timemachine.js
Expand Up @@ -11,4 +11,17 @@ describe("check timemachine", function () {
expect(new Date().toUTCString()).toBe('Wed, 25 Dec 1991 12:12:59 GMT');
});

it("should stay the same for instantiation with millisecond param", function() {
expect(new Date(1).toUTCString()).toBe('Thu, 01 Jan 1970 00:00:00 GMT');
});

it("should stay the same for instantiation with dateString", function() {
expect(new Date('December 25, 1991 13:12:59').toUTCString()).toBe('Wed, 25 Dec 1991 12:12:59 GMT');
});

it("should stay the same for instantiation with year, month, day, hours, minutes, seconds, milliseconds", function() {
expect(new Date(1990, 12, 25, 12, 12, 59, 1).toUTCString()).toBe('Fri, 25 Jan 1991 11:12:59 GMT');
});


});

0 comments on commit 66fb64f

Please sign in to comment.