Skip to content

Commit

Permalink
Merge pull request #74 from fatso83/pr-62-repacked
Browse files Browse the repository at this point in the history
PR #62 repacked (fixes #59).
  • Loading branch information
fatso83 authored Jul 13, 2016
2 parents f464603 + 2b4e22b commit 5d4310d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lolex-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@

for (i = 0, l = clock.methods.length; i < l; i++) {
method = clock.methods[i];
if (method === "hrtime") {
if (method === "hrtime" && target.process) {
target.process.hrtime = clock[installedHrTime];
} else {
if (target[method].hadOwnProperty) {
if (target[method] && target[method].hadOwnProperty) {
target[method] = clock["_" + method];
} else {
try {
Expand Down
15 changes: 15 additions & 0 deletions test/lolex-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ var GlobalDate = Date;
var NOOP = function NOOP() { return undefined; };
var hrtimePresent = (global.process && typeof global.process.hrtime === "function");

describe("issue #59", function () {
var context = {
Date: Date,
setTimeout: setTimeout,
clearTimeout: clearTimeout
};
var clock;

it("should install and uninstall the clock on a custom target", function () {
clock = lolex.install(context);
// this would throw an error before issue #59 was fixed
clock.uninstall();
});
});

describe("lolex", function () {

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

0 comments on commit 5d4310d

Please sign in to comment.