/* global expect, jasmine, describe, test, beforeAll, afterAll */ 'use strict' import { join } from 'path' import next from '../dist/server/next' const dir = join(__dirname, 'fixtures', 'basic') const app = next({ dir, dev: true, staticMarkup: true, quiet: true }) jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000 describe('integration tests', () => { beforeAll(() => app.prepare()) afterAll(() => app.close()) test('renders a stateless component', async () => { const html = await render('/stateless') expect(html.includes('')).toBeTruthy() expect(html.includes('
The answer is 42
Diego Milito
')).toBeTruthy() }) test('renders a link component', async () => { const html = await render('/link') expect(html.includes('About')).toBeTruthy() }) test('error', async () => { const html = await render('/error') expect(html).toMatch(/Error: This is an expected error\n[^]+<\/pre>/) }) test('error 404', async () => { const html = await render('/non-existent') expect(html).toMatch(/404<\/h1>/) expect(html).toMatch(/
This page could not be found\.<\/h2>/) }) test('finishes response', async () => { const res = { finished: false, end () { this.finished = true } } const html = await app.renderToHTML({}, res, '/finish-response', {}) expect(html).toBeFalsy() }) }) function render (pathname, query = {}) { return app.renderToHTML({}, {}, pathname, query) }