2017-11-20 07:13:53 +00:00
|
|
|
import test from 'ava'
|
|
|
|
import { resolve } from 'path'
|
|
|
|
import rp from 'request-promise-native'
|
2017-12-12 09:42:29 +00:00
|
|
|
import { Nuxt, Builder } from '..'
|
2017-12-17 19:30:26 +00:00
|
|
|
import { intercept, interceptWarn, release } from './helpers/console'
|
2017-11-20 07:13:53 +00:00
|
|
|
|
|
|
|
const port = 4010
|
|
|
|
const url = (route) => 'http://localhost:' + port + route
|
|
|
|
|
|
|
|
let nuxt = null
|
|
|
|
let builder = null
|
2017-12-17 19:30:26 +00:00
|
|
|
let buildSpies = null
|
2017-11-20 07:13:53 +00:00
|
|
|
|
|
|
|
// Init nuxt.js and create server listening on localhost:4000
|
2017-12-17 19:30:26 +00:00
|
|
|
test.serial('Init Nuxt.js', async t => {
|
2017-11-20 07:13:53 +00:00
|
|
|
const rootDir = resolve(__dirname, 'fixtures/deprecate')
|
|
|
|
let config = require(resolve(rootDir, 'nuxt.config.js'))
|
|
|
|
config.rootDir = rootDir
|
|
|
|
config.dev = false
|
|
|
|
|
2017-12-17 19:30:26 +00:00
|
|
|
buildSpies = await intercept(async () => {
|
|
|
|
nuxt = new Nuxt(config)
|
|
|
|
builder = await new Builder(nuxt)
|
|
|
|
await builder.build()
|
|
|
|
await nuxt.listen(port, 'localhost')
|
|
|
|
})
|
2017-11-20 07:13:53 +00:00
|
|
|
|
2017-12-17 19:30:26 +00:00
|
|
|
t.true(buildSpies.log.calledWithMatch('DONE'))
|
|
|
|
t.true(buildSpies.log.calledWithMatch('OPEN'))
|
2017-11-20 07:13:53 +00:00
|
|
|
})
|
|
|
|
|
2017-12-17 19:30:26 +00:00
|
|
|
test.serial('Deprecated: context.isServer and context.isClient', async t => {
|
|
|
|
const warnSpy = await interceptWarn()
|
2017-11-20 07:13:53 +00:00
|
|
|
await rp(url('/'))
|
2017-12-17 19:30:26 +00:00
|
|
|
t.true(warnSpy.calledWith('context.isServer has been deprecated, please use process.server instead.'))
|
|
|
|
t.true(warnSpy.calledWith('context.isClient has been deprecated, please use process.client instead.'))
|
|
|
|
t.true(warnSpy.calledTwice)
|
2017-12-13 05:38:46 +00:00
|
|
|
release()
|
2017-11-20 07:13:53 +00:00
|
|
|
})
|
|
|
|
|
2017-12-17 19:30:26 +00:00
|
|
|
test.serial('Deprecated: dev in build.extend()', async t => {
|
|
|
|
t.true(buildSpies.warn.withArgs('dev has been deprecated in build.extend(), please use isDev').calledTwice)
|
2017-11-20 07:13:53 +00:00
|
|
|
})
|
|
|
|
|
2017-12-17 19:30:26 +00:00
|
|
|
test.serial('Deprecated: nuxt.plugin()', async t => {
|
2017-11-20 07:13:53 +00:00
|
|
|
t.true(nuxt.__builder_plugin)
|
|
|
|
})
|
|
|
|
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
2017-12-17 19:30:26 +00:00
|
|
|
test.after.always('Closing server and nuxt.js', async t => {
|
|
|
|
await nuxt.close()
|
2017-11-20 07:13:53 +00:00
|
|
|
})
|