mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
add tests for dynamic routes
This commit is contained in:
parent
c4dfa34212
commit
61f9b21fd0
@ -27,50 +27,56 @@ test('Check .nuxt/router.js', t => {
|
||||
// pages/index.vue
|
||||
t.is(routes[0].path, '/')
|
||||
t.is(routes[0].name, 'index')
|
||||
// pages/test/songs/toto.vue
|
||||
t.is(routes[1].path, '/test/songs/toto')
|
||||
t.is(routes[1].name, 'test-songs-toto')
|
||||
// pages/test/songs/_id.vue
|
||||
t.is(routes[2].path, '/test/songs/:id?')
|
||||
t.is(routes[2].name, 'test-songs-id')
|
||||
// pages/test/users.vue
|
||||
t.is(routes[3].path, '/test/users')
|
||||
t.falsy(routes[3].name) // parent route has no name
|
||||
// pages/test/users/*.vue
|
||||
t.is(routes[3].children.length, 3) // parent has 3 children
|
||||
t.deepEqual(routes[3].children.map((r) => r.path), ['', ':index/teub', ':id'])
|
||||
t.deepEqual(routes[3].children.map((r) => r.name), ['test-users', 'test-users-index-teub', 'test-users-id'])
|
||||
// pages/users/_id.vue
|
||||
t.is(routes[4].path, '/users/:id?')
|
||||
t.is(routes[4].name, 'users-id')
|
||||
// pages/test/_.vue
|
||||
t.is(routes[5].path, '/test/*')
|
||||
t.is(routes[5].name, 'test-all')
|
||||
// pages/test/index.vue
|
||||
t.is(routes[6].path, '/test')
|
||||
t.is(routes[6].name, 'test')
|
||||
t.is(routes[1].path, '/test')
|
||||
t.is(routes[1].name, 'test')
|
||||
// pages/posts.vue
|
||||
t.is(routes[7].path, '/posts')
|
||||
t.is(routes[7].name, 'posts')
|
||||
t.is(routes[7].children.length, 1)
|
||||
t.is(routes[2].path, '/posts')
|
||||
t.is(routes[2].name, 'posts')
|
||||
t.is(routes[2].children.length, 1)
|
||||
// pages/posts/_id.vue
|
||||
t.is(routes[7].children[0].path, ':id?')
|
||||
t.is(routes[7].children[0].name, 'posts-id')
|
||||
t.is(routes[2].children[0].path, ':id?')
|
||||
t.is(routes[2].children[0].name, 'posts-id')
|
||||
// pages/parent.vue
|
||||
t.is(routes[8].path, '/parent')
|
||||
t.falsy(routes[8].name) // parent route has no name
|
||||
t.is(routes[3].path, '/parent')
|
||||
t.falsy(routes[3].name) // parent route has no name
|
||||
// pages/parent/*.vue
|
||||
t.is(routes[8].children.length, 3) // parent has 3 children
|
||||
t.deepEqual(routes[8].children.map((r) => r.path), ['', 'teub', 'child'])
|
||||
t.deepEqual(routes[8].children.map((r) => r.name), ['parent', 'parent-teub', 'parent-child'])
|
||||
// pages/_key/_id.vue
|
||||
t.is(routes[9].path, '/:key/:id?')
|
||||
t.is(routes[9].name, 'key-id')
|
||||
t.is(routes[3].children.length, 3) // parent has 3 children
|
||||
t.deepEqual(routes[3].children.map((r) => r.path), ['', 'teub', 'child'])
|
||||
t.deepEqual(routes[3].children.map((r) => r.name), ['parent', 'parent-teub', 'parent-child'])
|
||||
// pages/test/projects/index.vue
|
||||
t.is(routes[4].path, '/test/projects')
|
||||
t.is(routes[4].name, 'test-projects')
|
||||
// pages/test/users.vue
|
||||
t.is(routes[5].path, '/test/users')
|
||||
t.falsy(routes[5].name) // parent route has no name
|
||||
// pages/test/users/*.vue
|
||||
t.is(routes[5].children.length, 5) // parent has 5 children
|
||||
t.deepEqual(routes[5].children.map((r) => r.path), ['', 'projects', 'projects/:category', ':id', ':index/teub'])
|
||||
t.deepEqual(routes[5].children.map((r) => r.name), ['test-users', 'test-users-projects', 'test-users-projects-category', 'test-users-id', 'test-users-index-teub'])
|
||||
// pages/test/songs/toto.vue
|
||||
t.is(routes[6].path, '/test/songs/toto')
|
||||
t.is(routes[6].name, 'test-songs-toto')
|
||||
// pages/test/songs/_id.vue
|
||||
t.is(routes[7].path, '/test/songs/:id?')
|
||||
t.is(routes[7].name, 'test-songs-id')
|
||||
// pages/test/projects/_category.vue
|
||||
t.is(routes[8].path, '/test/projects/:category')
|
||||
t.is(routes[8].name, 'test-projects-category')
|
||||
// pages/users/_id.vue
|
||||
t.is(routes[9].path, '/users/:id?')
|
||||
t.is(routes[9].name, 'users-id')
|
||||
// pages/test/_.vue
|
||||
t.is(routes[10].path, '/test/*')
|
||||
t.is(routes[10].name, 'test-all')
|
||||
// pages/_slug.vue
|
||||
t.is(routes[10].path, '/:slug')
|
||||
t.is(routes[10].name, 'slug')
|
||||
t.is(routes[11].path, '/:slug')
|
||||
t.is(routes[11].name, 'slug')
|
||||
// pages/_key/_id.vue
|
||||
t.is(routes[12].path, '/:key/:id?')
|
||||
t.is(routes[12].name, 'key-id')
|
||||
// pages/_.vue
|
||||
t.is(routes[11].path, '/*')
|
||||
t.is(routes[11].name, 'all')
|
||||
t.is(routes[13].path, '/*')
|
||||
t.is(routes[13].name, 'all')
|
||||
})
|
||||
})
|
||||
|
0
test/fixtures/dynamic-routes/pages/test/projects/_category.vue
vendored
Normal file
0
test/fixtures/dynamic-routes/pages/test/projects/_category.vue
vendored
Normal file
0
test/fixtures/dynamic-routes/pages/test/projects/index.vue
vendored
Normal file
0
test/fixtures/dynamic-routes/pages/test/projects/index.vue
vendored
Normal file
0
test/fixtures/dynamic-routes/pages/test/users/projects/_category.vue
vendored
Normal file
0
test/fixtures/dynamic-routes/pages/test/users/projects/_category.vue
vendored
Normal file
0
test/fixtures/dynamic-routes/pages/test/users/projects/index.vue
vendored
Normal file
0
test/fixtures/dynamic-routes/pages/test/users/projects/index.vue
vendored
Normal file
Loading…
Reference in New Issue
Block a user