test: flatRoutes

This commit is contained in:
Clark Du 2018-04-03 21:44:59 +08:00
parent 89bdd71591
commit e4593e295d
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9

View File

@ -197,6 +197,25 @@ describe('utils', () => {
const chainedFn = Utils.chainFn(firstFn, secondFn)
expect(chainedFn({}, 10)).toEqual({ foo: 11, bar: 12 })
})
test('flatRoutes', () => {
const routes = Utils.flatRoutes([
{ name: 'login', path: '/login' },
{ name: 'about', path: '/about' },
{ name: 'posts',
path: '',
children: [
{ name: 'posts-list',
path: ''
},
{ name: 'posts-create',
path: 'post'
}
]
}
])
expect(routes).toMatchObject([ '/login', '/about', '', '/post' ])
})
})
test('createRoutes should allow snake case routes', () => {