test: rename custom-pages to custom-dirs and include tests for assets

This commit is contained in:
Ricardo Gobbo de Souza 2018-02-03 09:10:58 -02:00
parent fb29df43fd
commit ba5e608302
6 changed files with 16 additions and 6 deletions

View File

@ -8,7 +8,7 @@ let builder = null
// Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => {
const rootDir = resolve(__dirname, 'fixtures/custom-pages-dir')
const rootDir = resolve(__dirname, 'fixtures/custom-dirs')
let config = require(resolve(rootDir, 'nuxt.config.js'))
config.rootDir = rootDir
config.dev = false
@ -24,11 +24,16 @@ test.before('Init Nuxt.js', async t => {
t.true(logSpy.calledWithMatch('OPEN'))
})
test('/', async t => {
test('/ (custom pages directory)', async t => {
const { html } = await nuxt.renderRoute('/')
t.true(html.includes('<h1>I have custom pages directory</h1>'))
})
test('/ (custom assets directory)', async t => {
const { html } = await nuxt.renderRoute('/')
t.true(html.includes('.global-css-selector'))
})
// Close server and ask nuxt to stop listening to file changes
test.after.always('Closing server and nuxt.js', async t => {
await nuxt.close()

View File

@ -0,0 +1,3 @@
.global-css-selector {
color: red;
}

View File

@ -0,0 +1,5 @@
module.exports = {
assetsDir: 'custom-assets',
pagesDir: 'custom-pages',
css: [{ src: '~/custom-assets/app.css' }]
}

View File

@ -1,5 +1,5 @@
{
"name": "custom-pages-dir",
"name": "custom-dirs",
"version": "1.0.0",
"dependencies": {}
}

View File

@ -1,3 +0,0 @@
module.exports = {
pagesDir: 'custom-pages'
}