Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
dist
.next
yarn.lock
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"scripts": {
"build": "gulp",
"test": "ava"
"test": "gulp test"
},
"dependencies": {
"aphrodite": "0.5.0",
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/basic/pages/head.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import React from 'react'
import Head from 'next/head'

export default () => <div>
<Head>
<meta content="my meta" />
</Head>
<h1>I can haz meta tags</h1>
</div>
20 changes: 20 additions & 0 deletions test/fixtures/basic/pages/stateful.js
Original file line number Diff line number Diff line change
@@ -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 <div>
<p>The answer is {this.state.answer}</p>
</div>
}
}
15 changes: 13 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<h1>My component!</h1>'))
})

test(async (t) => {
test(async t => {
const html = await render('/css')
t.true(html.includes('<style data-aphrodite="">.red_im3wl1{color:red !important;}</style>'))
t.true(html.includes('<div class="red_im3wl1">This is red</div>'))
})

test(async t => {
const html = await (render('/stateful'))
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>'))
})

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