Add test for extendRoutes

This commit is contained in:
Sébastien Chopin 2017-01-19 16:26:30 +01:00
parent be6562f244
commit f8735dc450
2 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,15 @@
const resolve = require('path').resolve
module.exports = {
router: {
base: '/test/'
base: '/test/',
extendRoutes (routes) {
routes.push({
name: 'about-bis',
path: '/about-bis',
component: resolve(__dirname, 'pages/about.vue')
})
}
},
cache: true,
plugins: ['~plugins/test.js'],

View File

@ -47,6 +47,13 @@ test('/test/env', async t => {
t.true(html.includes('"string": "Nuxt.js"'))
})
test('/test/about-bis (added with extendRoutes)', async t => {
const window = await nuxt.renderAndGetWindow(url('/test/about-bis'))
const html = window.document.body.innerHTML
t.true(html.includes('<h1>Custom layout</h1>'))
t.true(html.includes('<h1>About page</h1>'))
})
// Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', t => {
server.close()