test: add deprecated cases for vendor and module

This commit is contained in:
Clark Du 2018-03-15 16:29:33 +08:00
parent f9ab3c4c7c
commit ca1c2b2ff3
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9
3 changed files with 16 additions and 2 deletions

View File

@ -58,6 +58,18 @@ test.serial('Deprecated: nuxt.plugin()', async t => {
t.true(nuxt.__builder_plugin)
})
test.serial('Deprecated: module.addVendor()', async t => {
t.true(buildSpies.warn.calledWithMatch('module: addVendor is no longer necessary'))
})
test.serial('Deprecated: module callback', async t => {
t.true(
buildSpies.warn.calledWithMatch(
'Supporting callbacks is deprecated and will be removed in next releases. Consider using async/await.'
)
)
})
test.serial('Error: nuxt.plugin()', async t => {
const error = t.throws(() => nuxt.plugin('build:done', () => {}))
t.is(error.message, 'nuxt.plugin(\'build:done\',..) is not supported. Use new hooks system.')

View File

@ -1,6 +1,8 @@
module.exports = function () {
module.exports = function basicModule(options, resolve) {
this.addVendor('lodash')
// Note: Plugin is deprecated. Please use new hooks system.
this.nuxt.plugin('built', (builder) => {
this.nuxt.__builder_plugin = true
})
resolve()
}

View File

@ -1,5 +1,5 @@
module.exports = {
modules: ['~/modules/hooks'],
modules: ['~/modules/deprecated-apis'],
build: {
stats: false,
extend(config, options) {