Skip to content

Commit

Permalink
fixed a case where runAll was called and there are no timers (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
CurtisHumphrey authored and fatso83 committed Jun 15, 2016
1 parent 9ac6a76 commit f464603
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lolex-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@
clock.runAll = function runAll() {
var numTimers, i;
for (i = 0; i < clock.loopLimit; i++) {
if (!clock.timers) {
return clock.now;
}

numTimers = Object.keys(clock.timers).length;
if (numTimers === 0) {
return clock.now;
Expand Down
5 changes: 5 additions & 0 deletions test/lolex-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,11 @@ describe("lolex", function () {

describe('runAll', function() {

it('if there are no timers just return', function() {
this.clock = lolex.createClock();
this.clock.runAll();
});

it('runs all timers', function() {
this.clock = lolex.createClock();
var spies = [sinon.spy(), sinon.spy()];
Expand Down

0 comments on commit f464603

Please sign in to comment.