Add test when no build and call render

This commit is contained in:
Sébastien Chopin 2016-12-09 23:29:04 +01:00
parent 6b7062046e
commit 3606d2a576

View File

@ -1,14 +1,37 @@
import test from 'ava'
const Nuxt = require('../')
const nuxt = new Nuxt()
import { resolve } from 'path'
test('Nuxt.js Class', (t) => {
const Nuxt = require('../')
test('Nuxt.js Class', t => {
t.is(typeof Nuxt, 'function')
})
test('Nuxt.js Instance', (t) => {
test('Nuxt.js Instance', t => {
const nuxt = new Nuxt()
t.is(typeof nuxt, 'object')
t.is(nuxt.dev, true)
t.is(typeof nuxt.build, 'function')
t.is(typeof nuxt.generate, 'function')
})
test('Fail when build not done and try to render', async t => {
const nuxt = new Nuxt({
dev: false,
rootDir: resolve(__dirname, 'empty')
})
return new Promise((resolve) => {
var oldExit = process.exit
var oldCE = console.error // eslint-disable-line no-console
var _log = ''
console.error = (s) => { _log += s } // eslint-disable-line no-console
process.exit = (code) => {
process.exit = oldExit
console.error = oldCE // eslint-disable-line no-console
t.is(code, 1)
t.true(_log.includes('No build files found'))
resolve()
}
nuxt.render()
})
})