Nuxt/test/index.test.js
Pooya Parsa 9b8cbed512 perf: remove rollup build
Using native node 8.x for less transpilations
2017-12-12 13:12:29 +03:30

43 lines
1.2 KiB
JavaScript

import test from 'ava'
import { resolve } from 'path'
import { Nuxt, Builder } from '..'
test('Nuxt.js Class', t => {
t.is(typeof Nuxt, 'function')
})
test.serial('Nuxt.js Instance', async t => {
const nuxt = new Nuxt({
rootDir: resolve(__dirname, 'fixtures', 'empty')
})
t.is(typeof nuxt, 'object')
t.is(nuxt.options.dev, true)
t.is(typeof nuxt._ready.then, 'function')
await nuxt.ready()
t.is(nuxt.initialized, true)
})
test.serial('Fail to build when no pages/ directory but is in the parent', t => {
const nuxt = new Nuxt({
dev: false,
rootDir: resolve(__dirname, 'fixtures', 'empty', 'pages')
})
return new Builder(nuxt).build().catch(err => {
let s = String(err)
t.true(s.includes('No `pages` directory found'))
t.true(s.includes('Did you mean to run `nuxt` in the parent (`../`) directory?'))
})
})
test.serial('Fail to build when no pages/ directory', t => {
const nuxt = new Nuxt({
dev: false,
rootDir: resolve(__dirname)
})
return new Builder(nuxt).build().catch(err => {
let s = String(err)
t.true(s.includes('Couldn\'t find a `pages` directory'))
t.true(s.includes('Please create one under the project root'))
})
})