-
Notifications
You must be signed in to change notification settings - Fork 156
/
dist.test.js
48 lines (39 loc) · 1.18 KB
/
dist.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
import { h } from 'preact';
import { toBeCloneOf } from './utils/assert-clone-of';
// import '../test_helpers/assert-clone-of';
const router = require('../dist/preact-router.js');
const { Router, Link, route } = router;
describe('dist', () => {
beforeAll(() => {
jasmine.addMatchers({ toBeCloneOf });
});
it('should export Router, Link and route', () => {
expect(Router).toBeInstanceOf(Function);
expect(Link).toBeInstanceOf(Function);
expect(route).toBeInstanceOf(Function);
expect(router).toBe(Router);
});
describe('Router', () => {
let children = [
<foo path="/" />,
<foo path="/foo" />,
<foo path="/foo/bar" />
];
it('should be instantiable', () => {
let router = new Router({});
expect(router).toBeInstanceOf(Router);
});
it('should filter children (manual)', () => {
let router = new Router({});
expect(
router.render({ children }, { url: '/foo' }).props.children
).toBeCloneOf(children[1], { url: '/foo' });
expect(
router.render({ children }, { url: '/' }).props.children
).toBeCloneOf(children[0]);
expect(
router.render({ children }, { url: '/foo/bar' }).props.children
).toBeCloneOf(children[2]);
});
});
});