Skip to content

Commit 100bc68

Browse files
committed
test: test parent and children properties in routes
1 parent deb8af4 commit 100bc68

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

test/unit/specs/create-map.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ describe('Creating Route Map', function () {
6868
expect(maps.nameMap.bar.children[0].name).toEqual('bar.baz')
6969
})
7070

71+
it('has bar route in bar parent', () => {
72+
expect(maps.nameMap['bar.baz'].parent.name).toEqual('bar')
73+
})
74+
75+
it('has no parent on /', () => {
76+
expect(maps.nameMap.home.parent).toEqual(undefined)
77+
})
78+
7179
it('in development, has logged a warning concerning named route of parent and default subroute', function () {
7280
process.env.NODE_ENV = 'development'
7381
maps = createRouteMap(routes)

test/unit/specs/create-matcher.spec.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,19 @@ describe('Creating Matcher', function () {
4545
expect(route.children[0].name).toEqual('foo.baz')
4646
})
4747

48-
it('should return the matched route with parent populated', () => {
48+
it('should return the matched route with its parent', () => {
4949
const route = match({ name: 'foo.baz' })
5050
expect(route.parent.name).toEqual('foo')
5151
})
52+
53+
it('should have an empty children array when no children', () => {
54+
const route = match({ name: 'home' })
55+
expect(route.children).toEqual([])
56+
})
57+
58+
it('should return the matched route with its children', () => {
59+
const route = match({ name: 'foo' })
60+
expect(route.children.length).toEqual(1)
61+
expect(route.children[0].name).toEqual('foo.baz')
62+
})
5263
})

0 commit comments

Comments
 (0)