mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
Move to fixtures and add generate test
This commit is contained in:
parent
a7e2a87ee4
commit
a03b13c2c1
@ -37,7 +37,7 @@
|
||||
"scripts": {
|
||||
"test": "nyc ava test/",
|
||||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
||||
"lint": "eslint --ext .js,.vue bin lib pages test --ignore-pattern lib/app",
|
||||
"lint": "eslint --ext .js,.vue bin lib pages test/*.js --ignore-pattern lib/app",
|
||||
"build": "webpack",
|
||||
"watch": "webpack --watch",
|
||||
"precommit": "npm run lint",
|
||||
|
23
test/basic.generate.test.js
Normal file
23
test/basic.generate.test.js
Normal file
@ -0,0 +1,23 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import pify from 'pify'
|
||||
import fs from 'fs'
|
||||
const readFile = pify(fs.readFile)
|
||||
|
||||
let nuxt = null
|
||||
|
||||
// Init nuxt.js and create server listening on localhost:4000
|
||||
test.before('Init Nuxt.js', async t => {
|
||||
const Nuxt = require('../')
|
||||
const options = {
|
||||
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||
dev: false
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
await nuxt.generate()
|
||||
})
|
||||
|
||||
test('/stateless', async t => {
|
||||
const html = await readFile(resolve(__dirname, 'fixtures/basic/dist/stateless/index.html'), 'utf8')
|
||||
t.true(html.includes('<h1>My component!</h1>'))
|
||||
})
|
@ -7,19 +7,17 @@ let nuxt = null
|
||||
let server = null
|
||||
|
||||
// Init nuxt.js and create server listening on localhost:4000
|
||||
test.before('Init Nuxt.js', t => {
|
||||
test.before('Init Nuxt.js', async t => {
|
||||
const Nuxt = require('../')
|
||||
const options = {
|
||||
rootDir: resolve(__dirname, 'basic'),
|
||||
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||
dev: false
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
return nuxt.build()
|
||||
.then(function () {
|
||||
await nuxt.build()
|
||||
server = new nuxt.Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
})
|
||||
})
|
||||
|
||||
test('/stateless', async t => {
|
||||
const { html } = await nuxt.renderRoute('/stateless')
|
||||
|
@ -7,19 +7,17 @@ let nuxt = null
|
||||
let server = null
|
||||
|
||||
// Init nuxt.js and create server listening on localhost:4000
|
||||
test.before('Init Nuxt.js', t => {
|
||||
test.before('Init Nuxt.js', async t => {
|
||||
const Nuxt = require('../')
|
||||
const options = {
|
||||
rootDir: resolve(__dirname, 'children'),
|
||||
rootDir: resolve(__dirname, 'fixtures/children'),
|
||||
dev: false
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
return nuxt.build()
|
||||
.then(function () {
|
||||
await nuxt.build()
|
||||
server = new nuxt.Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
})
|
||||
})
|
||||
|
||||
test('/parent', async t => {
|
||||
const { html } = await nuxt.renderRoute('/parent')
|
||||
|
@ -7,19 +7,17 @@ let nuxt = null
|
||||
let server = null
|
||||
|
||||
// Init nuxt.js and create server listening on localhost:4000
|
||||
test.before('Init Nuxt.js', t => {
|
||||
test.before('Init Nuxt.js', async t => {
|
||||
const Nuxt = require('../')
|
||||
const options = {
|
||||
rootDir: resolve(__dirname, 'error'),
|
||||
rootDir: resolve(__dirname, 'fixtures/error'),
|
||||
dev: false
|
||||
}
|
||||
nuxt = new Nuxt(options)
|
||||
return nuxt.build()
|
||||
.then(function () {
|
||||
await nuxt.build()
|
||||
server = new nuxt.Server(nuxt)
|
||||
server.listen(port, 'localhost')
|
||||
})
|
||||
})
|
||||
|
||||
test('/ should display an error', async t => {
|
||||
try {
|
||||
|
@ -15,10 +15,10 @@ test('Nuxt.js Instance', t => {
|
||||
t.is(typeof nuxt.generate, 'function')
|
||||
})
|
||||
|
||||
test('Fail when build not done and try to render', async t => {
|
||||
test.serial('Fail when build not done and try to render', t => {
|
||||
const nuxt = new Nuxt({
|
||||
dev: false,
|
||||
rootDir: resolve(__dirname, 'empty')
|
||||
rootDir: resolve(__dirname, 'fixtures/empty')
|
||||
})
|
||||
return new Promise((resolve) => {
|
||||
var oldExit = process.exit
|
||||
@ -36,11 +36,12 @@ test('Fail when build not done and try to render', async t => {
|
||||
})
|
||||
})
|
||||
|
||||
test('Fail to build when no pages/ directory but is in the parent', async t => {
|
||||
test.serial('Fail to build when no pages/ directory but is in the parent', t => {
|
||||
const nuxt = new Nuxt({
|
||||
dev: false,
|
||||
rootDir: resolve(__dirname, 'empty', 'pages')
|
||||
})
|
||||
return new Promise((resolve) => {
|
||||
var oldExit = process.exit
|
||||
var oldCE = console.error // eslint-disable-line no-console
|
||||
var _log = ''
|
||||
@ -54,12 +55,14 @@ test('Fail to build when no pages/ directory but is in the parent', async t => {
|
||||
}
|
||||
nuxt.build()
|
||||
})
|
||||
})
|
||||
|
||||
test('Fail to build when no pages/ directory', async t => {
|
||||
test.serial('Fail to build when no pages/ directory', t => {
|
||||
const nuxt = new Nuxt({
|
||||
dev: false,
|
||||
rootDir: resolve(__dirname)
|
||||
})
|
||||
return new Promise((resolve) => {
|
||||
var oldExit = process.exit
|
||||
var oldCE = console.error // eslint-disable-line no-console
|
||||
var _log = ''
|
||||
@ -73,3 +76,4 @@ test('Fail to build when no pages/ directory', async t => {
|
||||
}
|
||||
nuxt.build()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user