From 6bc16c0118f85aa4325d896f56033dff13affd72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 10 Feb 2017 00:45:49 +0100 Subject: [PATCH] Update tests --- test/basic.generate.test.js | 2 +- test/fixtures/with-config/middleware/user-agent.js | 3 +++ test/fixtures/with-config/pages/user-agent.vue | 12 ++++++++++++ test/with-config.test.js | 8 +++++++- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/with-config/middleware/user-agent.js create mode 100644 test/fixtures/with-config/pages/user-agent.vue diff --git a/test/basic.generate.test.js b/test/basic.generate.test.js index 1c285d4a21..7799a1750f 100644 --- a/test/basic.generate.test.js +++ b/test/basic.generate.test.js @@ -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('

I am valid

')) + t.true(html.includes('I am valid')) }) test('/redirect should not be server-rendered', async t => { diff --git a/test/fixtures/with-config/middleware/user-agent.js b/test/fixtures/with-config/middleware/user-agent.js new file mode 100644 index 0000000000..097436a73d --- /dev/null +++ b/test/fixtures/with-config/middleware/user-agent.js @@ -0,0 +1,3 @@ +export default function (context) { + context.userAgent = context.isServer ? context.req.headers['user-agent'] : navigator.userAgent +} diff --git a/test/fixtures/with-config/pages/user-agent.vue b/test/fixtures/with-config/pages/user-agent.vue new file mode 100644 index 0000000000..ae815519bc --- /dev/null +++ b/test/fixtures/with-config/pages/user-agent.vue @@ -0,0 +1,12 @@ + + + diff --git a/test/with-config.test.js b/test/with-config.test.js index 42c4da447a..d79c91450a 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -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('
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