Skip to content

Commit

Permalink
clock.tick returns clock.now
Browse files Browse the repository at this point in the history
It is useful for clock.tick() to return the new value of now.
  • Loading branch information
mjackson committed Jan 19, 2013
1 parent 715dc5c commit 466f30f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/sinon/util/fake_timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ if (typeof sinon == "undefined") {
if (firstException) {
throw firstException;
}

return this.now;
},

firstTimerInRange: function (from, to) {
Expand Down
6 changes: 6 additions & 0 deletions test/sinon/util/fake_timers_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ buster.testCase("sinon.clock", {
assert.exception(function() {
clock.tick(1000);
});
},

"returns the current now value": function () {
var clock = this.clock;
var value = clock.tick(200);
assert.equals(clock.now, value);
}
},

Expand Down

0 comments on commit 466f30f

Please sign in to comment.