Skip to content

Commit

Permalink
Allow install to be called with date object
Browse files Browse the repository at this point in the history
  • Loading branch information
th3fallen authored and cjohansen committed Feb 25, 2017
1 parent d77a49b commit 5bd7dff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lolex-src.js
Expand Up @@ -610,8 +610,13 @@ function createClock(now, loopLimit) {
exports.createClock = createClock;

exports.install = function install(target, now, toFake, loopLimit) {
var i,
l;
var i, l;

if (target instanceof Date) {
toFake = now;
now = target.getTime();
target = null;
}

if (typeof target === "number") {
toFake = now;
Expand Down
8 changes: 8 additions & 0 deletions test/lolex-test.js
Expand Up @@ -41,6 +41,14 @@ describe("issue #59", function () {
});
});

describe('issue #73', function() {
it('should install with date object', function () {
var date = new Date('2015-09-25');
var clock = lolex.install(date);
assert.same(date.clock, clock);
});
});

describe("lolex", function () {

describe("setTimeout", function () {
Expand Down

0 comments on commit 5bd7dff

Please sign in to comment.