blob: f1e95ddb065639aa7bacbb02e76f15a27e32b57a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*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();
});
});
test('it calls callback with given context', function() {
var spy = sinon.spy();
var ctx = {};
return fastdom.measure(spy, ctx)
.then(function() {
sinon.assert.calledOn(spy, ctx);
});
});
});
|