Skip to content

Commit

Permalink
fix: reset high resolution timer on clock.reset (#209)
Browse files Browse the repository at this point in the history
Fixes #206
  • Loading branch information
SimenB authored and fatso83 committed Sep 18, 2018
1 parent 1278eaa commit f1f80da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lolex-src.js
Expand Up @@ -727,6 +727,7 @@ function withGlobal(_global) {
clock.timers = {};
clock.jobs = [];
clock.now = getEpoch(start);
clock.hrNow = 0;
};

clock.setSystemTime = function setSystemTime(systemTime) {
Expand Down
8 changes: 8 additions & 0 deletions test/lolex-test.js
Expand Up @@ -1308,6 +1308,14 @@ describe("lolex", function () {
assert.equals(clock.now, 10000);
clock.uninstall();
});

it("resets hrTime - issue #206", function () {
var clock = lolex.createClock();
clock.tick(100);
assert.equals(clock.hrNow, 100);
clock.reset();
assert.equals(clock.hrNow, 0);
});
});

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

0 comments on commit f1f80da

Please sign in to comment.