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:
parent
facd19b5a7
commit
7f89c39045
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
.next
|
.next
|
||||||
|
yarn.lock
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp",
|
"build": "gulp",
|
||||||
"test": "ava"
|
"test": "gulp test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"aphrodite": "0.5.0",
|
"aphrodite": "0.5.0",
|
||||||
|
|
10
test/fixtures/basic/pages/head.js
vendored
Normal file
10
test/fixtures/basic/pages/head.js
vendored
Normal 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
20
test/fixtures/basic/pages/stateful.js
vendored
Normal 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>
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,17 +7,28 @@ const dir = resolve(__dirname, 'fixtures', 'basic')
|
||||||
|
|
||||||
test.before(() => build(dir))
|
test.before(() => build(dir))
|
||||||
|
|
||||||
test(async (t) => {
|
test(async t => {
|
||||||
const html = await render('/stateless')
|
const html = await render('/stateless')
|
||||||
t.true(html.includes('<h1>My component!</h1>'))
|
t.true(html.includes('<h1>My component!</h1>'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test(async (t) => {
|
test(async t => {
|
||||||
const html = await render('/css')
|
const html = await render('/css')
|
||||||
t.true(html.includes('<style data-aphrodite="">.red_im3wl1{color:red !important;}</style>'))
|
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>'))
|
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) {
|
function render (url, ctx) {
|
||||||
return _render(url, ctx, { dir, staticMarkup: true })
|
return _render(url, ctx, { dir, staticMarkup: true })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue