diff --git a/.gitignore b/.gitignore index 2cceb5fd..a7018501 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules dist .next +yarn.lock diff --git a/package.json b/package.json index 3defb291..1121688f 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "scripts": { "build": "gulp", - "test": "ava" + "test": "gulp test" }, "dependencies": { "aphrodite": "0.5.0", diff --git a/test/fixtures/basic/pages/head.js b/test/fixtures/basic/pages/head.js new file mode 100644 index 00000000..7af9c5a7 --- /dev/null +++ b/test/fixtures/basic/pages/head.js @@ -0,0 +1,10 @@ + +import React from 'react' +import Head from 'next/head' + +export default () =>
+ + + +

I can haz meta tags

+
diff --git a/test/fixtures/basic/pages/stateful.js b/test/fixtures/basic/pages/stateful.js new file mode 100644 index 00000000..02248c42 --- /dev/null +++ b/test/fixtures/basic/pages/stateful.js @@ -0,0 +1,20 @@ + +import React, { Component } from 'react' + +export default class Statefull extends Component { + constructor (props) { + super(props) + + this.state = { answer: null } + } + + componentWillMount () { + this.setState({ answer: 42 }) + } + + render () { + return
+

The answer is {this.state.answer}

+
+ } +} diff --git a/test/index.js b/test/index.js index 54183c3c..d90a7844 100644 --- a/test/index.js +++ b/test/index.js @@ -7,17 +7,28 @@ const dir = resolve(__dirname, 'fixtures', 'basic') test.before(() => build(dir)) -test(async (t) => { +test(async t => { const html = await render('/stateless') t.true(html.includes('

My component!

')) }) -test(async (t) => { +test(async t => { const html = await render('/css') t.true(html.includes('')) t.true(html.includes('
This is red
')) }) +test(async t => { + const html = await (render('/stateful')) + t.true(html.includes('

The answer is 42

')) +}) + +test(async t => { + const html = await (render('/head')) + t.true(html.includes('')) + t.true(html.includes('

I can haz meta tags

')) +}) + function render (url, ctx) { return _render(url, ctx, { dir, staticMarkup: true }) }