Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Jun 2, 2021
1 parent f9e134d commit 217c918
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions playground/pages/index.vue
@@ -0,0 +1,29 @@
<template>
<div>
<h1>Special state in `window.__NUXT__`</h1>
<client-only><pre>{{ nuxtState }}</pre></client-only>
</div>
</template>

<script>
export default {
data () {
return {
nuxtState: null
}
},
fetch () {
if (process.server) {
this.$root.context.beforeNuxtRender(({ nuxtState }) => {
nuxtState.testBefore = true
})
this.$root.context.afterNuxtRender(({ nuxtState }) => {
nuxtState.testAfter = true
})
}
},
beforeMount () {
this.nuxtState = window.__NUXT__
}
}
</script>
1 change: 1 addition & 0 deletions test/dev/basic.ssr.test.js
Expand Up @@ -210,6 +210,7 @@ describe('basic ssr', () => {
test('/special-state-after -> check window.__NUXT__.testAfter = true', async () => {
const window = await nuxt.server.renderAndGetWindow(url('/special-state-after'))
expect(window.document.title).toBe('Nuxt')
expect(window.__NUXT__.testBefore).toBeUndefined()
expect(window.__NUXT__.testAfter).toBe(true)
})

Expand Down

0 comments on commit 217c918

Please sign in to comment.