2016-12-09 17:51:19 +00:00
|
|
|
import test from 'ava'
|
2016-12-09 22:29:04 +00:00
|
|
|
import { resolve } from 'path'
|
2017-12-12 09:42:29 +00:00
|
|
|
import { Nuxt, Builder } from '..'
|
2016-12-09 17:51:19 +00:00
|
|
|
|
2016-12-09 22:29:04 +00:00
|
|
|
test('Nuxt.js Class', t => {
|
2016-12-09 17:51:19 +00:00
|
|
|
t.is(typeof Nuxt, 'function')
|
|
|
|
})
|
|
|
|
|
2017-12-17 19:30:26 +00:00
|
|
|
test('Nuxt.js Instance', async t => {
|
2017-06-13 19:44:54 +00:00
|
|
|
const nuxt = new Nuxt({
|
2018-01-23 05:10:10 +00:00
|
|
|
dev: true,
|
2017-06-13 19:44:54 +00:00
|
|
|
rootDir: resolve(__dirname, 'fixtures', 'empty')
|
|
|
|
})
|
2016-12-09 17:51:19 +00:00
|
|
|
t.is(typeof nuxt, 'object')
|
2017-06-15 10:03:54 +00:00
|
|
|
t.is(nuxt.options.dev, true)
|
2017-06-15 22:38:43 +00:00
|
|
|
t.is(typeof nuxt._ready.then, 'function')
|
2017-06-15 14:59:26 +00:00
|
|
|
await nuxt.ready()
|
2017-06-15 22:38:43 +00:00
|
|
|
t.is(nuxt.initialized, true)
|
2016-12-09 22:29:04 +00:00
|
|
|
})
|
2016-12-10 09:57:50 +00:00
|
|
|
|
2017-12-17 19:30:26 +00:00
|
|
|
test('Fail to build when no pages/ directory but is in the parent', t => {
|
2017-05-31 14:21:16 +00:00
|
|
|
const nuxt = new Nuxt({
|
2017-06-13 22:09:03 +00:00
|
|
|
dev: false,
|
2016-12-20 19:54:23 +00:00
|
|
|
rootDir: resolve(__dirname, 'fixtures', 'empty', 'pages')
|
2016-12-10 09:57:50 +00:00
|
|
|
})
|
2017-06-18 17:33:23 +00:00
|
|
|
return new Builder(nuxt).build().catch(err => {
|
2017-06-13 22:09:03 +00:00
|
|
|
let s = String(err)
|
|
|
|
t.true(s.includes('No `pages` directory found'))
|
2018-01-13 05:22:11 +00:00
|
|
|
t.true(
|
|
|
|
s.includes('Did you mean to run `nuxt` in the parent (`../`) directory?')
|
|
|
|
)
|
2016-12-20 19:44:42 +00:00
|
|
|
})
|
2016-12-10 09:57:50 +00:00
|
|
|
})
|
|
|
|
|
2017-12-17 19:30:26 +00:00
|
|
|
test('Fail to build when no pages/ directory', t => {
|
2017-05-31 14:21:16 +00:00
|
|
|
const nuxt = new Nuxt({
|
2017-06-13 22:09:03 +00:00
|
|
|
dev: false,
|
2016-12-10 09:57:50 +00:00
|
|
|
rootDir: resolve(__dirname)
|
|
|
|
})
|
2017-06-18 17:33:23 +00:00
|
|
|
return new Builder(nuxt).build().catch(err => {
|
2017-06-13 22:09:03 +00:00
|
|
|
let s = String(err)
|
2018-01-13 05:22:11 +00:00
|
|
|
t.true(s.includes("Couldn't find a `pages` directory"))
|
2017-06-13 22:09:03 +00:00
|
|
|
t.true(s.includes('Please create one under the project root'))
|
2016-12-20 19:44:42 +00:00
|
|
|
})
|
2016-12-10 09:57:50 +00:00
|
|
|
})
|