test: snake case route names

This commit is contained in:
David Müller 2018-03-19 19:48:43 +01:00
parent 051be92ea5
commit 49cd2e92d2

View File

@ -198,3 +198,43 @@ describe('utils', () => {
expect(chainedFn({}, 10)).toEqual({ foo: 11, bar: 12 })
})
})
test('createRoutes should allow snake case routes', () => {
const files = [
'pages/_param.vue',
'pages/subpage/_param.vue',
'pages/snake_case_route.vue',
'pages/another_route/_id.vue'
]
const srcDir = '/some/nuxt/app'
const pagesDir = 'pages'
const routesResult = Utils.createRoutes(files, srcDir, pagesDir)
const expectedResult = [
{
name: 'snake_case_route',
path: '/snake_case_route',
component: Utils.r('/some/nuxt/app/pages/snake_case_route.vue'),
chunkName: 'pages/snake_case_route'
},
{
name: 'another_route-id',
path: '/another_route/:id?',
component: Utils.r('/some/nuxt/app/pages/another_route/_id.vue'),
chunkName: 'pages/another_route/_id'
},
{
name: 'subpage-param',
path: '/subpage/:param?',
component: Utils.r('/some/nuxt/app/pages/subpage/_param.vue'),
chunkName: 'pages/subpage/_param'
},
{
name: 'param',
path: '/:param?',
component: Utils.r('/some/nuxt/app/pages/_param.vue'),
chunkName: 'pages/_param'
}
]
expect(routesResult).toEqual(expectedResult)
})