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

Set test command and added more tests

This commit is contained in:
Dan Zajdband 2016-10-12 19:15:58 -04:00
parent facd19b5a7
commit 7f89c39045
5 changed files with 45 additions and 3 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
node_modules
dist
.next
yarn.lock

View file

@ -12,7 +12,7 @@
},
"scripts": {
"build": "gulp",
"test": "ava"
"test": "gulp test"
},
"dependencies": {
"aphrodite": "0.5.0",

10
test/fixtures/basic/pages/head.js vendored Normal file
View file

@ -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
test/fixtures/basic/pages/stateful.js vendored Normal file
View file

@ -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>
}
}

View file

@ -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 })
}