diff --git a/test/deprecate.test.js b/test/deprecate.test.js new file mode 100755 index 0000000000..e6ae186066 --- /dev/null +++ b/test/deprecate.test.js @@ -0,0 +1,55 @@ +import test from 'ava' +import stdMocks from 'std-mocks' +import { resolve } from 'path' +import rp from 'request-promise-native' +import { Nuxt, Builder } from '../index.js' + +const port = 4010 +const url = (route) => 'http://localhost:' + port + route + +let nuxt = null +let builder = null +let builtErr = null + +// Init nuxt.js and create server listening on localhost:4000 +test.before('Init Nuxt.js', async t => { + const rootDir = resolve(__dirname, 'fixtures/deprecate') + let config = require(resolve(rootDir, 'nuxt.config.js')) + config.rootDir = rootDir + config.dev = false + nuxt = new Nuxt(config) + builder = new Builder(nuxt) + + stdMocks.use({ + stdout: false, + stderr: true + }) + await builder.build() + stdMocks.restore() + builtErr = stdMocks.flush().stderr + + await nuxt.listen(port, 'localhost') +}) + +test('Deprecated: context.isServer and context.isClient', async t => { + stdMocks.use() + await rp(url('/')) + stdMocks.restore() + const output = stdMocks.flush() + t.true(output.stderr.length === 2) +}) + +test('Deprecated: dev in build.extend()', async t => { + const deprecatedMsg = 'dev has been deprecated in build.extend(), please use isDev' + const errors = builtErr.filter(value => value.indexOf(deprecatedMsg) === 0) + t.true(errors.length === 2) +}) + +test('Deprecated: nuxt.plugin()', async t => { + t.true(nuxt.__builder_plugin) +}) + +// Close server and ask nuxt to stop listening to file changes +test.after('Closing server and nuxt.js', t => { + nuxt.close() +}) diff --git a/test/fixtures/debug/nuxt.config.js b/test/fixtures/debug/nuxt.config.js index 2e05a7cd6e..2bb2464225 100644 --- a/test/fixtures/debug/nuxt.config.js +++ b/test/fixtures/debug/nuxt.config.js @@ -3,6 +3,9 @@ module.exports = { base: '/test/' }, debug: true, + build: { + scopeHoisting: true + }, editor: { cmd: 'echo', pattern: '' diff --git a/test/fixtures/deprecate/modules/hooks/index.js b/test/fixtures/deprecate/modules/hooks/index.js new file mode 100644 index 0000000000..883fe0e0ba --- /dev/null +++ b/test/fixtures/deprecate/modules/hooks/index.js @@ -0,0 +1,6 @@ +module.exports = function () { + // Note: Plugin is deprecated. Please use new hooks system. + this.nuxt.plugin('built', (builder) => { + this.nuxt.__builder_plugin = true + }) +} diff --git a/test/fixtures/deprecate/nuxt.config.js b/test/fixtures/deprecate/nuxt.config.js new file mode 100755 index 0000000000..2fc7d1f9ba --- /dev/null +++ b/test/fixtures/deprecate/nuxt.config.js @@ -0,0 +1,12 @@ +module.exports = { + modules: [ + '~/modules/hooks' + ], + build: { + extend(config, options) { + if (options.dev) { + // Please use isDev instead of dev + } + } + } +} diff --git a/test/fixtures/deprecate/package.json b/test/fixtures/deprecate/package.json new file mode 100755 index 0000000000..ccdd12ba4a --- /dev/null +++ b/test/fixtures/deprecate/package.json @@ -0,0 +1,5 @@ +{ + "name": "deprecated-apis", + "version": "1.0.0", + "dependencies": {} +} diff --git a/test/fixtures/deprecate/pages/about.vue b/test/fixtures/deprecate/pages/about.vue new file mode 100644 index 0000000000..93009e1b3e --- /dev/null +++ b/test/fixtures/deprecate/pages/about.vue @@ -0,0 +1,6 @@ + diff --git a/test/fixtures/deprecate/pages/index.vue b/test/fixtures/deprecate/pages/index.vue new file mode 100755 index 0000000000..600aa6eb97 --- /dev/null +++ b/test/fixtures/deprecate/pages/index.vue @@ -0,0 +1,13 @@ + + + diff --git a/test/fixtures/with-config/nuxt.config.js b/test/fixtures/with-config/nuxt.config.js index 5454ed2a36..34012a7fc1 100644 --- a/test/fixtures/with-config/nuxt.config.js +++ b/test/fixtures/with-config/nuxt.config.js @@ -46,9 +46,6 @@ module.exports = { generateStatsFile: true }, extend(config, options) { - if (options.dev) { - // Please use isDev instead of dev - } return Object.assign({}, config, { devtool: 'nosources-source-map' }) diff --git a/test/module.test.js b/test/module.test.js index 3baf9782ac..d8fceedfb1 100755 --- a/test/module.test.js +++ b/test/module.test.js @@ -63,13 +63,6 @@ test('Hooks - Error', async t => { t.true(errors.length === 1) }) -// Note: Plugin is deprecated. Please use new hooks system. -test('Plugin', async t => { - t.is(nuxt.__builder_plugin, 4) - const error = builtErr.filter(value => value.indexOf('deprecated') >= 0) - t.true(error.length === 1) -}) - // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close() diff --git a/test/with-config.test.js b/test/with-config.test.js index 20c3a25bab..f179df1e39 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -1,6 +1,5 @@ import test from 'ava' import { resolve } from 'path' -import stdMocks from 'std-mocks' import rp from 'request-promise-native' import { Nuxt, Builder } from '../index.js' @@ -8,7 +7,6 @@ const port = 4007 const url = (route) => 'http://localhost:' + port + route let nuxt = null -let builtErr = null // Init nuxt.js and create server listening on localhost:4000 test.before('Init Nuxt.js', async t => { @@ -17,15 +15,7 @@ test.before('Init Nuxt.js', async t => { config.rootDir = rootDir config.dev = false nuxt = new Nuxt(config) - - stdMocks.use({ - stdout: false, - stderr: true - }) await new Builder(nuxt).build() - stdMocks.restore() - builtErr = stdMocks.flush().stderr - await nuxt.listen(port, 'localhost') }) @@ -133,12 +123,6 @@ test('Check /test.txt should return 404', async t => { t.is(err.response.statusCode, 404) }) -test('Check deprecated dev in build.extend()', async t => { - const deprecatedMsg = 'dev has been deprecated in build.extend(), please use isDev\n' - const errors = builtErr.filter(value => value === deprecatedMsg) - t.true(errors.length === 2) -}) - // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close()