Update tests

This commit is contained in:
Sébastien Chopin 2017-02-10 00:45:49 +01:00
parent d698cb4dca
commit 6bc16c0118
4 changed files with 23 additions and 2 deletions

View File

@ -101,7 +101,7 @@ test('/validate -> should display a 404', async t => {
test('/validate?valid=true', async t => {
const window = await nuxt.renderAndGetWindow(url('/validate?valid=true'))
const html = window.document.body.innerHTML
t.true(html.includes('<h1>I am valid</h1>'))
t.true(html.includes('I am valid</h1>'))
})
test('/redirect should not be server-rendered', async t => {

View File

@ -0,0 +1,3 @@
export default function (context) {
context.userAgent = context.isServer ? context.req.headers['user-agent'] : navigator.userAgent
}

View File

@ -0,0 +1,12 @@
<template>
<pre>{{ userAgent }}</pre>
</template>
<script>
export default {
middleware: 'user-agent',
data ({ userAgent }) {
return { userAgent }
}
}
</script>

View File

@ -47,6 +47,12 @@ test('/test/env', async t => {
t.true(html.includes('"string": "Nuxt.js"'))
})
test('/test/user-agent', async t => {
const window = await nuxt.renderAndGetWindow(url('/test/user-agent'))
const html = window.document.body.innerHTML
t.true(html.includes('<pre>Node.js'))
})
test('/test/about-bis (added with extendRoutes)', async t => {
const window = await nuxt.renderAndGetWindow(url('/test/about-bis'))
const html = window.document.body.innerHTML
@ -56,7 +62,7 @@ test('/test/about-bis (added with extendRoutes)', async t => {
test('Check stats.json generated by build.analyze', t => {
const stats = require(resolve(__dirname, 'fixtures/with-config/.nuxt/dist/stats.json'))
t.is(stats.assets.length, 10)
t.is(stats.assets.length, 11)
})
// Close server and ask nuxt to stop listening to file changes