Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Feb 9, 2017
1 parent d698cb4 commit 6bc16c0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/basic.generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/with-config/middleware/user-agent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function (context) {
context.userAgent = context.isServer ? context.req.headers['user-agent'] : navigator.userAgent
}
12 changes: 12 additions & 0 deletions test/fixtures/with-config/pages/user-agent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<pre>{{ userAgent }}</pre>
</template>

<script>
export default {
middleware: 'user-agent',
data ({ userAgent }) {
return { userAgent }
}
}
</script>
8 changes: 7 additions & 1 deletion test/with-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6bc16c0

Please sign in to comment.