test: add client-only test to basic fixture (#6315)

test: check for no-ssr deprecation warning
This commit is contained in:
Pim 2019-08-27 11:25:25 +02:00 committed by Sébastien Chopin
parent 61ef86e015
commit b286024dd3
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<template>
<div>
<client-only placeholder="Loading..." placeholder-tag="p">
<h1>Displayed only on client-side</h1>
</client-only>
</div>
</template>

View File

@ -262,6 +262,19 @@ describe('basic ssr', () => {
expect(redirected.status === 302).toBe(true)
})
test('/client-only', async () => {
const { html } = await nuxt.server.renderRoute('/client-only')
expect(html.includes(
'<p class="client-only-placeholder">Loading...</p>'
)).toBe(true)
})
test('/client-only (client-side)', async () => {
const window = await nuxt.server.renderAndGetWindow(url('/client-only'))
const html = window.document.body.innerHTML
expect(html).toContain('Displayed only on client-side</h1>')
})
test('/no-ssr', async () => {
const { html } = await nuxt.server.renderRoute('/no-ssr')
expect(html.includes(
@ -273,6 +286,10 @@ describe('basic ssr', () => {
const window = await nuxt.server.renderAndGetWindow(url('/no-ssr'))
const html = window.document.body.innerHTML
expect(html).toContain('Displayed only on client-side</h1>')
expect(consola.warn).toHaveBeenCalledTimes(1)
expect(consola.warn).toHaveBeenCalledWith(
expect.stringContaining('<no-ssr> has been deprecated')
)
})
test('ETag Header', async () => {