diff --git a/test/fixtures/module/modules/tapable/index.js b/test/fixtures/module/modules/tapable/index.js new file mode 100644 index 0000000000..58b879c0fc --- /dev/null +++ b/test/fixtures/module/modules/tapable/index.js @@ -0,0 +1,18 @@ +module.exports = function () { + let ctr = 1 + + // Add hook for module + this.nuxt.plugin('module', async moduleContainer => { + this.nuxt.__module_hook = moduleContainer && ctr++ + }) + + // Add hook for renderer + this.nuxt.plugin('renderer', async renderer => { + this.nuxt.__renderer_hook = renderer && ctr++ + }) + + // Add hook for build + this.nuxt.plugin('build', async builder => { + this.nuxt.__builder_hook = builder && ctr++ + }) +} diff --git a/test/fixtures/module/modules/template/index.js b/test/fixtures/module/modules/template/index.js index d68d9546a8..6033364d55 100644 --- a/test/fixtures/module/modules/template/index.js +++ b/test/fixtures/module/modules/template/index.js @@ -3,6 +3,7 @@ const path = require('path') module.exports = function () { // Disable parsing pages/ this.nuxt.options.build.createRoutes = () => {} + // Add /api endpoint this.addTemplate({ fileName: 'router.js', diff --git a/test/fixtures/module/nuxt.config.js b/test/fixtures/module/nuxt.config.js index 26f1351403..9b53c2a7d1 100755 --- a/test/fixtures/module/nuxt.config.js +++ b/test/fixtures/module/nuxt.config.js @@ -1,7 +1,8 @@ module.exports = { loading: true, modules: [ - '~/modules/basic', // Use ~ for deprication warning coverage + '~/modules/basic', + '~/modules/tapable', { src: '~/modules/middleware', options: { diff --git a/test/module.test.js b/test/module.test.js index 9f1f7d0b57..83f3005c4c 100755 --- a/test/module.test.js +++ b/test/module.test.js @@ -37,6 +37,12 @@ test('Middleware', async t => { t.is(response, 'It works!', '/api response is correct') }) +test('Tapable', async t => { + t.is(nuxt.__module_hook, 1) + t.is(nuxt.__renderer_hook, 2) + t.is(nuxt.__builder_hook, 3) +}) + // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close()