Created
December 23, 2014 11:30
-
-
Save acnalesso/12351f6066bdeda45c5e to your computer and use it in GitHub Desktop.
queue#flush test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("Queue#flush should be recursive if new items are added", function() { | |
expect(2); | |
var bb = new Backburner(['one']); | |
var count = 0; | |
bb.run(function(){ | |
function increment() { | |
if (++count < 3) { | |
bb.schedule('one', increment); | |
} | |
if (count === 3) { | |
bb.schedule('one', increment); | |
} | |
} | |
increment(); | |
equal(count, 1, 'should not have run yet'); | |
bb.currentInstance.queues.one.flush(); | |
equal(count, 4, 'should have run all scheduled methods, even ones added during flush'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment