mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 14:41:25 +00:00
Update tests
This commit is contained in:
parent
d698cb4dca
commit
6bc16c0118
@ -101,7 +101,7 @@ test('/validate -> should display a 404', async t => {
|
|||||||
test('/validate?valid=true', async t => {
|
test('/validate?valid=true', async t => {
|
||||||
const window = await nuxt.renderAndGetWindow(url('/validate?valid=true'))
|
const window = await nuxt.renderAndGetWindow(url('/validate?valid=true'))
|
||||||
const html = window.document.body.innerHTML
|
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 => {
|
test('/redirect should not be server-rendered', async t => {
|
||||||
|
3
test/fixtures/with-config/middleware/user-agent.js
vendored
Normal file
3
test/fixtures/with-config/middleware/user-agent.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default function (context) {
|
||||||
|
context.userAgent = context.isServer ? context.req.headers['user-agent'] : navigator.userAgent
|
||||||
|
}
|
12
test/fixtures/with-config/pages/user-agent.vue
vendored
Normal file
12
test/fixtures/with-config/pages/user-agent.vue
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<template>
|
||||||
|
<pre>{{ userAgent }}</pre>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
middleware: 'user-agent',
|
||||||
|
data ({ userAgent }) {
|
||||||
|
return { userAgent }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -47,6 +47,12 @@ test('/test/env', async t => {
|
|||||||
t.true(html.includes('"string": "Nuxt.js"'))
|
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 => {
|
test('/test/about-bis (added with extendRoutes)', async t => {
|
||||||
const window = await nuxt.renderAndGetWindow(url('/test/about-bis'))
|
const window = await nuxt.renderAndGetWindow(url('/test/about-bis'))
|
||||||
const html = window.document.body.innerHTML
|
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 => {
|
test('Check stats.json generated by build.analyze', t => {
|
||||||
const stats = require(resolve(__dirname, 'fixtures/with-config/.nuxt/dist/stats.json'))
|
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
|
// Close server and ask nuxt to stop listening to file changes
|
||||||
|
Loading…
Reference in New Issue
Block a user