Skip to content

Instantly share code, notes, and snippets.

@acnalesso
Created December 23, 2014 11:30
Show Gist options
  • Save acnalesso/12351f6066bdeda45c5e to your computer and use it in GitHub Desktop.
Save acnalesso/12351f6066bdeda45c5e to your computer and use it in GitHub Desktop.
queue#flush test
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