-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathgroup.method.js
76 lines (64 loc) · 1.78 KB
/
group.method.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const catchable = (done, fn) => {
try {
fn();
} catch (e) {
done(e);
}
};
describe('Group', () => {
const router = new Router();
context('Common', () => {
context('Methods', () => {
it('should set and retrieve group name', done => {
const rand = Random.id(),
name = Random.id(),
group = new Group(router, {name}),
timer = setTimeout(Meteor.bindEnvironment(() => {done();}), 50);
group.route(`/${rand}`, {
action() {
expect(router.current().route.group.name).to.be.equal(name);
clearTimeout(timer);
done();
}
});
router.go(`/${rand}`);
});
context('Route', () => {
const prefix = Random.id(),
rand = Random.id();
it('should work with prefix', done => {
const group = new Group(router, {prefix: `/${prefix}`});
let rendered = 0;
group.route(`/${rand}`, {
action: function() {
rendered++;
}
});
router.go(`/${prefix}/${rand}`);
Meteor.setTimeout(() => {
catchable(done, () => {
if (Meteor.isClient) expect(rendered).to.be.equal(1);
done();
});
}, 50);
});
it('should work without prefix', done => {
const group = new Group(router);
let rendered = 0;
group.route(`/${rand}`, {
action() {
rendered++;
}
});
router.go(`/${rand}`);
Meteor.setTimeout(() => {
catchable(done, () => {
if (Meteor.isClient) expect(rendered).to.be.equal(1);
done();
});
}, 50);
});
});
});
});
});