update tests

This commit is contained in:
Pooya Parsa 2017-06-16 17:19:35 +04:30
parent 829ffa634b
commit 45485f5b8a
11 changed files with 20 additions and 19 deletions

View File

@ -1,6 +1,8 @@
import test from 'ava' import test from 'ava'
import { resolve } from 'path' import { resolve } from 'path'
import rp from 'request-promise-native' import rp from 'request-promise-native'
import { Nuxt, Server } from '../index.js'
const port = 4001 const port = 4001
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
@ -9,14 +11,13 @@ let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
const Nuxt = require('../')
const options = { const options = {
rootDir: resolve(__dirname, 'fixtures/basic'), rootDir: resolve(__dirname, 'fixtures/basic'),
dev: true dev: true
} }
nuxt = new Nuxt(options) nuxt = new Nuxt(options)
await nuxt.ready() await nuxt.ready()
server = new Nuxt.Server(nuxt) server = new Server(nuxt)
server.listen(port, 'localhost') server.listen(port, 'localhost')
}) })
@ -38,5 +39,6 @@ test('/_nuxt/test.hot-update.json should returns empty html', async t => {
// Close server and ask nuxt to stop listening to file changes // Close server and ask nuxt to stop listening to file changes
test.after('Closing server and nuxt.js', t => { test.after('Closing server and nuxt.js', t => {
server.close() server.close()
nuxt.close(() => {}) nuxt.close(() => {
})
}) })

View File

@ -1,8 +1,8 @@
import test from 'ava' import test from 'ava'
import { resolve } from 'path' import { resolve } from 'path'
import { Nuxt } from '../index.js'
test('Fail with routes() which throw an error', async t => { test('Fail with routes() which throw an error', async t => {
const Nuxt = require('../')
const options = { const options = {
rootDir: resolve(__dirname, 'fixtures/basic'), rootDir: resolve(__dirname, 'fixtures/basic'),
dev: false, dev: false,

View File

@ -4,6 +4,7 @@ import http from 'http'
import serveStatic from 'serve-static' import serveStatic from 'serve-static'
import finalhandler from 'finalhandler' import finalhandler from 'finalhandler'
import rp from 'request-promise-native' import rp from 'request-promise-native'
import { Nuxt } from '../index.js'
const port = 4002 const port = 4002
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
@ -13,7 +14,6 @@ let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
const Nuxt = require('../')
const rootDir = resolve(__dirname, 'fixtures/basic') const rootDir = resolve(__dirname, 'fixtures/basic')
let config = require(resolve(rootDir, 'nuxt.config.js')) let config = require(resolve(rootDir, 'nuxt.config.js'))
config.rootDir = rootDir config.rootDir = rootDir

View File

@ -2,6 +2,7 @@ import test from 'ava'
import { resolve } from 'path' import { resolve } from 'path'
import rp from 'request-promise-native' import rp from 'request-promise-native'
import stdMocks from 'std-mocks' import stdMocks from 'std-mocks'
import { Nuxt, Server } from '../index.js'
const port = 4003 const port = 4003
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
@ -11,7 +12,6 @@ let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
const Nuxt = require('../')
const options = { const options = {
rootDir: resolve(__dirname, 'fixtures/basic'), rootDir: resolve(__dirname, 'fixtures/basic'),
dev: false, dev: false,
@ -19,7 +19,7 @@ test.before('Init Nuxt.js', async t => {
} }
nuxt = new Nuxt(options) nuxt = new Nuxt(options)
await nuxt.ready() await nuxt.ready()
server = new Nuxt.Server(nuxt) server = new Server(nuxt)
server.listen(port, 'localhost') server.listen(port, 'localhost')
}) })

View File

@ -1,5 +1,6 @@
import test from 'ava' import test from 'ava'
import { resolve } from 'path' import { resolve } from 'path'
import { Nuxt, Server } from '../index.js'
const port = 4004 const port = 4004
// const url = (route) => 'http://localhost:' + port + route // const url = (route) => 'http://localhost:' + port + route
@ -9,7 +10,6 @@ let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
const Nuxt = require('../')
const options = { const options = {
rootDir: resolve(__dirname, 'fixtures/children'), rootDir: resolve(__dirname, 'fixtures/children'),
dev: false, dev: false,
@ -17,7 +17,7 @@ test.before('Init Nuxt.js', async t => {
} }
nuxt = new Nuxt(options) nuxt = new Nuxt(options)
await nuxt.ready() await nuxt.ready()
server = new Nuxt.Server(nuxt) server = new Server(nuxt)
server.listen(port, 'localhost') server.listen(port, 'localhost')
}) })

View File

@ -2,11 +2,11 @@ import test from 'ava'
import { resolve } from 'path' import { resolve } from 'path'
import fs from 'fs' import fs from 'fs'
import pify from 'pify' import pify from 'pify'
import { Nuxt } from '../index.js'
const readFile = pify(fs.readFile) const readFile = pify(fs.readFile)
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
const Nuxt = require('../')
const nuxt = new Nuxt({ const nuxt = new Nuxt({
rootDir: resolve(__dirname, 'fixtures/dynamic-routes'), rootDir: resolve(__dirname, 'fixtures/dynamic-routes'),
dev: false, dev: false,

View File

@ -1,5 +1,6 @@
import test from 'ava' import test from 'ava'
import { resolve } from 'path' import { resolve } from 'path'
import { Nuxt, Server } from '../index.js'
const port = 4005 const port = 4005
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
@ -9,7 +10,6 @@ let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
const Nuxt = require('../')
const options = { const options = {
rootDir: resolve(__dirname, 'fixtures/error'), rootDir: resolve(__dirname, 'fixtures/error'),
dev: false, dev: false,
@ -17,7 +17,7 @@ test.before('Init Nuxt.js', async t => {
} }
nuxt = new Nuxt(options) nuxt = new Nuxt(options)
await nuxt.ready() await nuxt.ready()
server = new Nuxt.Server(nuxt) server = new Server(nuxt)
server.listen(port, 'localhost') server.listen(port, 'localhost')
}) })

View File

@ -1,7 +1,6 @@
import test from 'ava' import test from 'ava'
import { resolve } from 'path' import { resolve } from 'path'
import { Nuxt } from '../index.js'
const Nuxt = require('../')
test('Nuxt.js Class', t => { test('Nuxt.js Class', t => {
t.is(typeof Nuxt, 'function') t.is(typeof Nuxt, 'function')

View File

@ -1,7 +1,7 @@
import test from 'ava' import test from 'ava'
import { resolve, normalize } from 'path' import { resolve, normalize } from 'path'
import rp from 'request-promise-native' import rp from 'request-promise-native'
import Nuxt from '..' import { Nuxt, Server } from '../index.js'
const port = 4006 const port = 4006
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
@ -18,7 +18,7 @@ test.before('Init Nuxt.js', async t => {
config.runBuild = true config.runBuild = true
nuxt = new Nuxt(config) nuxt = new Nuxt(config)
await nuxt.ready() await nuxt.ready()
server = new Nuxt.Server(nuxt) server = new Server(nuxt)
server.listen(port, 'localhost') server.listen(port, 'localhost')
}) })

View File

@ -1,6 +1,6 @@
import test from 'ava' import test from 'ava'
import ansiHTML from 'ansi-html' import ansiHTML from 'ansi-html'
import { Utils } from '..' import { Utils } from '../index.js'
test('encodeHtml', t => { test('encodeHtml', t => {
const html = '<h1>Hello</h1>' const html = '<h1>Hello</h1>'

View File

@ -1,6 +1,7 @@
import test from 'ava' import test from 'ava'
import { resolve } from 'path' import { resolve } from 'path'
import rp from 'request-promise-native' import rp from 'request-promise-native'
import { Nuxt, Server } from '../index.js'
const port = 4007 const port = 4007
const url = (route) => 'http://localhost:' + port + route const url = (route) => 'http://localhost:' + port + route
@ -10,7 +11,6 @@ let server = null
// Init nuxt.js and create server listening on localhost:4000 // Init nuxt.js and create server listening on localhost:4000
test.before('Init Nuxt.js', async t => { test.before('Init Nuxt.js', async t => {
const Nuxt = require('../')
const rootDir = resolve(__dirname, 'fixtures/with-config') const rootDir = resolve(__dirname, 'fixtures/with-config')
let config = require(resolve(rootDir, 'nuxt.config.js')) let config = require(resolve(rootDir, 'nuxt.config.js'))
config.rootDir = rootDir config.rootDir = rootDir
@ -18,7 +18,7 @@ test.before('Init Nuxt.js', async t => {
config.runBuild = true config.runBuild = true
nuxt = new Nuxt(config) nuxt = new Nuxt(config)
await nuxt.ready() await nuxt.ready()
server = new Nuxt.Server(nuxt) server = new Server(nuxt)
server.listen(port, 'localhost') server.listen(port, 'localhost')
}) })