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
|
// @flow
import { expect } from 'chai';
import TransitionRule from '../app/lib/transition-rule';
describe('TransitionRule', () => {
const testTransition = {
forward: { name: 'forward', duration: 0.25 },
backward: { name: 'backward', duration: 0.25 }
};
it('should match wildcard rule', () => {
const rule = new TransitionRule(null, '/route', testTransition);
expect(rule.match(null, '/route')).to.deep.equal({
direction: 'forward',
descriptor: { name: 'forward', duration: 0.25 }
});
expect(rule.match('/somewhere', '/route')).to.deep.equal({
direction: 'forward',
descriptor: { name: 'forward', duration: 0.25 }
});
});
it('should match wildcard rule reversion', () => {
const rule = new TransitionRule(null, '/route', testTransition);
expect(rule.match('/route', '/other')).to.deep.equal({
direction: 'backward',
descriptor: { name: 'backward', duration: 0.25 }
});
});
it('should match exact rule', () => {
const rule = new TransitionRule('/route1', '/route2', testTransition);
expect(rule.match('/other', '/route1')).to.be.null;
expect(rule.match('/other', '/route2')).to.be.null;
expect(rule.match('/route1', '/route2')).to.deep.equal({
direction: 'forward',
descriptor: { name: 'forward', duration: 0.25 }
});
});
it('should match exact rule reversion', () => {
const rule = new TransitionRule('/route1', '/route2', testTransition);
expect(rule.match('/route1', '/other')).to.be.null;
expect(rule.match('/route2', '/other')).to.be.null;
expect(rule.match('/route2', '/route1')).to.deep.equal({
direction: 'backward',
descriptor: { name: 'backward', duration: 0.25 }
});
});
});
|