diff options
author | Wilson Page <wilsonpage@me.com> | 2013-10-25 17:06:45 +0100 |
---|---|---|
committer | Wilson Page <wilsonpage@me.com> | 2013-10-25 17:06:45 +0100 |
commit | 3cdcef0b54d1f5c357faddfdea22c08b85f702a7 (patch) | |
tree | f0a84cd3b0af850d53af38e433af8a616eccbddd | |
parent | 96819c04ff24045b716769ba3b97df09df44b3a5 (diff) | |
download | fastdom-3cdcef0b54d1f5c357faddfdea22c08b85f702a7.zip fastdom-3cdcef0b54d1f5c357faddfdea22c08b85f702a7.tar.gz fastdom-3cdcef0b54d1f5c357faddfdea22c08b85f702a7.tar.bz2 |
Prove that errors thrown in read/write jobs clog the queue
-rw-r--r-- | test/test.set.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test.set.js b/test/test.set.js index d0eea9b..93c3efe 100644 --- a/test/test.set.js +++ b/test/test.set.js @@ -282,4 +282,38 @@ suite('set', function() { done(); }); }); + + + test.only('Should continue to flush the queue until empty even if a job errors', function(done) { + var fastdom = new FastDom(); + var read = sinon.spy(); + var write = sinon.spy(); + var flush = fastdom.runBatch; + var error = sinon.stub().throws(); + var errorsThrown = false; + + sinon.stub(fastdom, 'runBatch', function() { + try { + flush.apply(fastdom, arguments); + } catch (e) { + errorsThrown = true; + } + }); + + fastdom.read(read); + fastdom.write(write); + fastdom.read(error); + fastdom.read(read); + fastdom.write(error); + fastdom.write(write); + + raf(function() { + assert(read.calledTwice, 'the callback was called both times'); + assert(write.calledTwice, 'the callback was called both times'); + assert(fastdom.batch.read.length === 0, 'the queue is empty'); + assert(fastdom.batch.write.length === 0, 'the queue is empty'); + assert(errorsThrown, 'real errors were thrown'); + done(); + }); + }); }); |