1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Fix production tests.

This commit is contained in:
Arunoda Susiripala 2017-04-05 08:18:15 +05:30
parent 03209d88fd
commit a1f11a4660
3 changed files with 19 additions and 27 deletions

View file

@ -0,0 +1,3 @@
export default () => (
<div className='about-page'>About Page</div>
)

View file

@ -1,3 +1,8 @@
import Link from 'next/link'
export default () => (
<div>Hello World</div>
<div>
<Link href='/about'><a>About Page</a></Link>
<p>Hello World</p>
</div>
)

View file

@ -1,6 +1,5 @@
/* global jasmine, describe, it, expect, beforeAll, afterAll */
import fetch from 'node-fetch'
import { join } from 'path'
import {
nextServer,
@ -9,6 +8,7 @@ import {
stopApp,
renderViaHTTP
} from 'next-test-utils'
import webdriver from 'next-webdriver'
const appDir = join(__dirname, '../')
let appPort
@ -37,32 +37,16 @@ describe('Production Usage', () => {
})
})
describe('JSON pages', () => {
describe('when asked for a normal page', () => {
it('should serve the normal page', async () => {
const url = `http://localhost:${appPort}/_next/${app.renderOpts.buildId}/pages`
const res = await fetch(url, { compress: false })
expect(res.headers.get('Content-Encoding')).toBeNull()
describe('With navigation', () => {
it('should navigate via client side', async () => {
const browser = await webdriver(appPort, '/')
const text = await browser
.elementByCss('a').click()
.waitForElementByCss('.about-page')
.elementByCss('div').text()
const page = await res.json()
expect(page.component).toBeDefined()
})
})
describe('when asked for a page with an unknown encoding', () => {
it('should serve the normal page', async () => {
const url = `http://localhost:${appPort}/_next/${app.renderOpts.buildId}/pages`
const res = await fetch(url, {
compress: false,
headers: {
'Accept-Encoding': 'br'
}
})
expect(res.headers.get('Content-Encoding')).toBeNull()
const page = await res.json()
expect(page.component).toBeDefined()
})
expect(text).toBe('About Page')
browser.close()
})
})
})