mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
test(module): add tests for tapable
This commit is contained in:
parent
b5ca6b7975
commit
f317b70fd5
18
test/fixtures/module/modules/tapable/index.js
vendored
Normal file
18
test/fixtures/module/modules/tapable/index.js
vendored
Normal file
@ -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++
|
||||||
|
})
|
||||||
|
}
|
@ -3,6 +3,7 @@ const path = require('path')
|
|||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
// Disable parsing pages/
|
// Disable parsing pages/
|
||||||
this.nuxt.options.build.createRoutes = () => {}
|
this.nuxt.options.build.createRoutes = () => {}
|
||||||
|
|
||||||
// Add /api endpoint
|
// Add /api endpoint
|
||||||
this.addTemplate({
|
this.addTemplate({
|
||||||
fileName: 'router.js',
|
fileName: 'router.js',
|
||||||
|
3
test/fixtures/module/nuxt.config.js
vendored
3
test/fixtures/module/nuxt.config.js
vendored
@ -1,7 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
loading: true,
|
loading: true,
|
||||||
modules: [
|
modules: [
|
||||||
'~/modules/basic', // Use ~ for deprication warning coverage
|
'~/modules/basic',
|
||||||
|
'~/modules/tapable',
|
||||||
{
|
{
|
||||||
src: '~/modules/middleware',
|
src: '~/modules/middleware',
|
||||||
options: {
|
options: {
|
||||||
|
@ -37,6 +37,12 @@ test('Middleware', async t => {
|
|||||||
t.is(response, 'It works!', '/api response is correct')
|
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
|
// 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 => {
|
||||||
nuxt.close()
|
nuxt.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user