summaryrefslogtreecommitdiffstats
path: root/test/test.set.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/test.set.js')
-rw-r--r--test/test.set.js36
1 files changed, 29 insertions, 7 deletions
diff --git a/test/test.set.js b/test/test.set.js
index 440848d..f5b2ae3 100644
--- a/test/test.set.js
+++ b/test/test.set.js
@@ -59,11 +59,17 @@ suite('set', function() {
assert(!cb.called);
done();
});
+
+ // Should not have scheduled a new frame
+ assert(fastdom.frames.length === 0);
});
});
test('Should call a write in the same frame if scheduled inside a read callback', function(done) {
var fastdom = new FastDom();
+
+ fastdom.catchErrors = false;
+
var cb = sinon.spy();
fastdom.read(function() {
@@ -80,6 +86,9 @@ suite('set', function() {
assert(!cb.called);
done();
});
+
+ // Should not have scheduled a new frame
+ assert(fastdom.frames.length === 0);
});
});
@@ -100,6 +109,9 @@ suite('set', function() {
assert(cb.called);
done();
});
+
+ // Should not have scheduled a new frame
+ assert(fastdom.frames.length === 1);
});
});
@@ -134,10 +146,10 @@ suite('set', function() {
fastdom.write(function(){});
// Check there are four jobs stored
- assert.equal(objectLength(fastdom.jobs), 4);
+ assert.equal(objectLength(fastdom.queue.hash), 4);
raf(function() {
- assert.equal(objectLength(fastdom.jobs), 0);
+ assert.equal(objectLength(fastdom.queue.hash), 0);
done();
});
});
@@ -162,12 +174,12 @@ suite('set', function() {
});
});
- test('Should call a registered onError handler when an error is thrown inside a job', function(done) {
+ test('Should no error if the `quiet` flag is set', function(done) {
var fastdom = new FastDom();
var err1 = { some: 'error1' };
var err2 = { some: 'error2' };
- fastdom.onError = sinon.spy();
+ fastdom.quiet = true;
fastdom.read(function() {
throw err1;
@@ -178,9 +190,19 @@ suite('set', function() {
});
raf(function() {
- assert(fastdom.onError.calledTwice);
- assert(fastdom.onError.getCall(0).calledWith(err1));
- assert(fastdom.onError.getCall(1).calledWith(err2));
+ done();
+ });
+ });
+
+ test('Should stop rAF loop once frame queue is empty', function(done) {
+ var fastdom = new FastDom();
+ var callback = sinon.spy();
+
+ fastdom.read(callback);
+
+ raf(function() {
+ assert(callback.called);
+ assert(fastdom.looping === false);
done();
});
});