-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
69 lines (60 loc) · 1.39 KB
/
test.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
import test from 'ava';
import fn from '.';
// const TEST_DATA = [
// '/category',
// '/category/page',
// '/{cat}/b',
// '/{cat}/{page}',
// '/category{cat}/{page}',
// '/category-{cat}/{page}',
// '/category-{cat}/page{page}',
// '/category-{cat}/page-{page}',
// '/category-{cat}/page-{page}-with-comments',
// '/category-{cat}/page-{page}-with-{component}',
// '/category-{cat}/{page}-with-{component}',
// '/{cat}{page}{component}',
// '/{cat}/{page}{component}',
// '/{cat}/{page}/{component}',
// ];
test('can match url', t => {
const routes = {
'/category'() {
t.pass();
}
};
fn(routes, '/category');
});
test('can match url with params', t => {
const routes = {
'/category-{cat}/page-{page}-with-{component}'(params) {
t.deepEqual(params, {
cat: '1',
page: '2',
component: '3'
});
}
};
fn(routes, '/category-1/page-2-with-3');
});
test('can can trig more than one urls', t => {
t.plan(2);
const routes = {
'/category-{cat}/page-{page}-with-{component}'(params) {
t.deepEqual(params, {
cat: '1',
page: '2',
component: '3'
});
t.pass();
},
'/category-123/page-456-with-769'() {
t.pass();
}
};
fn(routes, '/category-1/page-2-with-3');
});
// test('title', t => {
// const err = t.throws(() => fn(123), TypeError);
// t.is(err.message, 'Expected a string, got number');
// t.is(fn('unicorns'), 'unicorns & rainbows');
// });