mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-04 03:17:14 +00:00
Add test for custom state
This commit is contained in:
parent
8e79e7ce42
commit
15400e1828
@ -101,6 +101,11 @@ test('/redirect -> check redirected source', async t => {
|
|||||||
t.true(html.includes('<h1>Index page</h1>'))
|
t.true(html.includes('<h1>Index page</h1>'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test.only('/special-state -> check window.__NUXT__.test = true', async t => {
|
||||||
|
const window = await nuxt.renderAndGetWindow(url('/special-state'))
|
||||||
|
t.is(window.__NUXT__.test, true)
|
||||||
|
})
|
||||||
|
|
||||||
test('/error', async t => {
|
test('/error', async t => {
|
||||||
try {
|
try {
|
||||||
await nuxt.renderRoute('/error', { req: {}, res: {} })
|
await nuxt.renderRoute('/error', { req: {}, res: {} })
|
||||||
|
15
test/fixtures/basic/pages/special-state.vue
vendored
Normal file
15
test/fixtures/basic/pages/special-state.vue
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<template>
|
||||||
|
<h1>Special state in `window.__NUXT__`</h1>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
fetch ({ isServer, beforeNuxtRender }) {
|
||||||
|
if (isServer) {
|
||||||
|
beforeNuxtRender(({ nuxtState }) => {
|
||||||
|
nuxtState.test = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
2
test/fixtures/with-config/nuxt.config.js
vendored
2
test/fixtures/with-config/nuxt.config.js
vendored
@ -14,7 +14,7 @@ module.exports = {
|
|||||||
transition: 'test',
|
transition: 'test',
|
||||||
offline: true,
|
offline: true,
|
||||||
plugins: [
|
plugins: [
|
||||||
'~/plugins/test.js', // Use ~ for deprication warning coverage
|
'~/plugins/test.js',
|
||||||
{ src: '~/plugins/only-client.js', ssr: false }
|
{ src: '~/plugins/only-client.js', ssr: false }
|
||||||
],
|
],
|
||||||
loading: '~/components/loading',
|
loading: '~/components/loading',
|
||||||
|
Loading…
Reference in New Issue
Block a user