diff options
author | Wilson Page <wilsonpage@me.com> | 2015-02-13 19:49:50 +0000 |
---|---|---|
committer | Wilson Page <wilsonpage@me.com> | 2016-01-04 12:21:44 +0000 |
commit | 4ade1a6b6b14fcef9686ab9eb03e6e4951b948fc (patch) | |
tree | 1cf3226ef4b51cbd069bc01ca15343f081646657 /test/fastdom-promised-test.js | |
parent | 6c4958941d2c86cdfa6dc17a8b286399f3f71729 (diff) | |
download | fastdom-origin/v1-beta.zip fastdom-origin/v1-beta.tar.gz fastdom-origin/v1-beta.tar.bz2 |
Diffstat (limited to 'test/fastdom-promised-test.js')
-rw-r--r-- | test/fastdom-promised-test.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/fastdom-promised-test.js b/test/fastdom-promised-test.js new file mode 100644 index 0000000..959800e --- /dev/null +++ b/test/fastdom-promised-test.js @@ -0,0 +1,48 @@ +/*global suite, setup, test, assert, sinon, fastdomPromised*/ +/*jshint maxlen:false*/ + +suite('fastdom-promised', function() { + var fastdom; + + setup(function() { + fastdom = window.fastdom.extend(fastdomPromised); + }); + + test('it returns a Promise that resolves after the task is run', function(done) { + var spy = sinon.spy(); + + fastdom.measure(spy) + .then(function() { + sinon.assert.calledOnce(spy); + done(); + }); + }); + + test('promises can be returned from tasks', function() { + var spy1 = sinon.spy(); + var spy2 = sinon.spy(); + + return fastdom.measure(function() { + spy1(); + return fastdom.mutate(spy2); + }) + + .then(function() { + sinon.assert.calledOnce(spy1); + sinon.assert.calledOnce(spy2); + assert.isTrue(spy1.calledBefore(spy2)); + }); + }); + + test('calling `fastdom.clear(promise)` works', function(done) { + var spy = sinon.spy(); + var task = fastdom.measure(spy); + + fastdom.clear(task); + + requestAnimationFrame(function() { + sinon.assert.notCalled(spy); + done(); + }); + }); +}); |