mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
test: render:context hook
This commit is contained in:
parent
7514db73b2
commit
25d752630a
13
test/fixtures/module/modules/hooks/index.js
vendored
13
test/fixtures/module/modules/hooks/index.js
vendored
@ -2,21 +2,26 @@ export default function () {
|
||||
let ctr = 1
|
||||
|
||||
// Add hook for module
|
||||
this.nuxt.hook('modules:done', (moduleContainer) => {
|
||||
this.nuxt.hook('modules:done', moduleContainer => {
|
||||
this.nuxt.__module_hook = moduleContainer && ctr++
|
||||
})
|
||||
|
||||
// Add hook for renderer
|
||||
this.nuxt.hook('render:done', (renderer) => {
|
||||
this.nuxt.hook('render:done', renderer => {
|
||||
this.nuxt.__renderer_hook = renderer && ctr++
|
||||
})
|
||||
|
||||
// Get data before data sent to client
|
||||
this.nuxt.hook('render:context', data => {
|
||||
this.nuxt.__render_context = data
|
||||
})
|
||||
|
||||
// Add hook for build
|
||||
this.nuxt.hook('build:done', (builder) => {
|
||||
this.nuxt.hook('build:done', builder => {
|
||||
this.nuxt.__builder_hook = builder && ctr++
|
||||
})
|
||||
|
||||
this.nuxt.hook('build:done', (builder) => {
|
||||
this.nuxt.hook('build:done', builder => {
|
||||
this.nuxt.__builder_plugin = builder && ctr++
|
||||
})
|
||||
}
|
||||
|
@ -53,6 +53,11 @@ describe('module', () => {
|
||||
expect(response).toBe('Use external middleware')
|
||||
})
|
||||
|
||||
test('Hooks - render context', async () => {
|
||||
await nuxt.renderRoute('/render-context')
|
||||
expect(nuxt.__render_context).toBeTruthy()
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
afterAll(async () => {
|
||||
await nuxt.close()
|
||||
|
Loading…
Reference in New Issue
Block a user