2016-10-10 04:25:08 +00:00
|
|
|
import test from 'ava'
|
2016-10-19 12:58:08 +00:00
|
|
|
import { join } from 'path'
|
2016-10-10 04:25:08 +00:00
|
|
|
import build from '../server/build'
|
|
|
|
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
|
|
|
|
|
|
|
test.before(() => build(dir))
|
|
|
|
|
2016-10-12 23:15:58 +00:00
|
|
|
test(async t => {
|
2016-10-10 04:25:08 +00:00
|
|
|
const html = await render('/stateless')
|
|
|
|
t.true(html.includes('<h1>My component!</h1>'))
|
|
|
|
})
|
|
|
|
|
2016-10-12 23:15:58 +00:00
|
|
|
test(async t => {
|
2016-10-10 04:35:37 +00:00
|
|
|
const html = await render('/css')
|
2016-10-21 16:39:20 +00:00
|
|
|
t.true(html.includes('.css-im3wl1'))
|
|
|
|
t.true(html.includes('<div class="css-im3wl1">This is red</div>'))
|
2016-10-10 04:35:37 +00:00
|
|
|
})
|
|
|
|
|
2016-10-12 23:15:58 +00:00
|
|
|
test(async t => {
|
2016-10-16 04:32:58 +00:00
|
|
|
const html = await render('/stateful')
|
2016-10-12 23:15:58 +00:00
|
|
|
t.true(html.includes('<div><p>The answer is 42</p></div>'))
|
|
|
|
})
|
|
|
|
|
|
|
|
test(async t => {
|
|
|
|
const html = await (render('/head'))
|
|
|
|
t.true(html.includes('<meta content="my meta" class="next-head"/>'))
|
|
|
|
t.true(html.includes('<div><h1>I can haz meta tags</h1></div>'))
|
|
|
|
})
|
|
|
|
|
2016-10-16 04:32:58 +00:00
|
|
|
test(async t => {
|
|
|
|
const html = await render('/async-props')
|
|
|
|
t.true(html.includes('<p>Diego Milito</p>'))
|
|
|
|
})
|
|
|
|
|
2016-10-10 04:25:08 +00:00
|
|
|
function render (url, ctx) {
|
|
|
|
return _render(url, ctx, { dir, staticMarkup: true })
|
|
|
|
}
|