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

54 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-12-12 12:31:49 +00:00
/* global expect, jasmine, describe, test, beforeAll */
'use strict'
2016-10-10 04:25:08 +00:00
import build from '../server/build'
2016-12-12 12:31:49 +00:00
import { join } from 'path'
2016-10-10 04:25:08 +00:00
import { render as _render } from '../server/render'
2016-10-19 12:58:08 +00:00
const dir = join(__dirname, 'fixtures', 'basic')
2016-10-10 04:25:08 +00:00
2016-12-12 12:31:49 +00:00
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000
describe('integration tests', () => {
beforeAll(() => build(dir))
test('renders a stateless component', async () => {
const html = await render('/stateless')
expect(html.includes('<meta charset="utf-8" class="next-head"/>')).toBeTruthy()
expect(html.includes('<h1>My component!</h1>')).toBeTruthy()
})
test('renders a stateful component', async () => {
const html = await render('/stateful')
expect(html.includes('<div><p>The answer is 42</p></div>')).toBeTruthy()
})
test('header helper renders header information', async () => {
const html = await (render('/head'))
expect(html.includes('<meta charset="iso-8859-5" class="next-head"/>')).toBeTruthy()
expect(html.includes('<meta content="my meta" class="next-head"/>')).toBeTruthy()
expect(html.includes('<div><h1>I can haz meta tags</h1></div>')).toBeTruthy()
})
test('css helper renders styles', async () => {
const html = await render('/css')
expect(/\.css-\w+/.test(html)).toBeTruthy()
expect(/<div class="css-\w+">This is red<\/div>/.test(html)).toBeTruthy()
})
test('renders properties populated asynchronously', async () => {
const html = await render('/async-props')
expect(html.includes('<p>Diego Milito</p>')).toBeTruthy()
})
test('renders a link component', async () => {
const html = await render('/link')
expect(html.includes('<a href="/about">About</a>')).toBeTruthy()
})
2016-11-15 08:24:20 +00:00
})
2016-10-10 04:25:08 +00:00
function render (url, ctx) {
return _render(url, ctx, { dir, staticMarkup: true })
}