-
Notifications
You must be signed in to change notification settings - Fork 7
/
transitioner_tests.js
50 lines (42 loc) · 1.33 KB
/
transitioner_tests.js
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
Tinytest.addAsync("Transitioner variable changes", function(test, done) {
Meteor.Router.add({'/foo': 'foo', '/bar': 'bar'});
Meteor.Router.to('/foo');
Meteor.flush();
var transitioner = Meteor.Transitioner;
test.equal(transitioner.currentPage(), 'foo');
test.equal(transitioner.nextPage(), null);
Meteor.Router.to('/bar');
Meteor.flush();
test.equal(transitioner.currentPage(), 'foo');
test.equal(transitioner.nextPage(), 'bar');
// the transition takes 1 ms, but we really need to wait longer
Meteor.setTimeout(function() {
test.equal(transitioner.currentPage(), 'bar');
test.equal(transitioner.nextPage(), null);
done()
}, 100);
});
Tinytest.addAsync("Transitioner callbacks", function(test, done) {
Meteor.Router.add({'/foo': 'foo', '/bar': 'bar'});
Meteor.Router.to('/foo');
Meteor.flush();
var beforeDone = false, afterDone = false;
Meteor.Transitioner.setOptions({
before: function() {
beforeDone = true;
},
after: function() {
afterDone = true;
}
});
test.equal(beforeDone, false);
test.equal(afterDone, false);
Meteor.Router.to('/bar');
Meteor.flush();
// the transition takes 1 ms, but we really need to wait longer
Meteor.setTimeout(function() {
test.equal(beforeDone, true);
test.equal(afterDone, true);
done()
}, 100);
});