Skip to content

Commit

Permalink
test: add client-only test to basic fixture (#6315)
Browse files Browse the repository at this point in the history
test: check for no-ssr deprecation warning
  • Loading branch information
pimlie authored and atinux committed Aug 27, 2019
1 parent 61ef86e commit b286024
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/fixtures/basic/pages/client-only.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<div>
<client-only placeholder="Loading..." placeholder-tag="p">
<h1>Displayed only on client-side</h1>
</client-only>
</div>
</template>
17 changes: 17 additions & 0 deletions test/unit/basic.ssr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 () => {
Expand Down

0 comments on commit b286024

Please sign in to comment.