mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Added async props test (#9)
This commit is contained in:
parent
e527098bb9
commit
78fa6b191d
18
test/fixtures/basic/pages/async-props.js
vendored
Normal file
18
test/fixtures/basic/pages/async-props.js
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default class AsyncProps extends React.Component {
|
||||||
|
static async getInitialProps () {
|
||||||
|
return await AsyncProps.fetchData()
|
||||||
|
}
|
||||||
|
|
||||||
|
static fetchData () {
|
||||||
|
const p = new Promise(resolve => {
|
||||||
|
setTimeout(() => resolve({ name: 'Diego Milito' }), 10)
|
||||||
|
})
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
return <p>{this.props.name}</p>
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ test(async t => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test(async t => {
|
test(async t => {
|
||||||
const html = await (render('/stateful'))
|
const html = await render('/stateful')
|
||||||
t.true(html.includes('<div><p>The answer is 42</p></div>'))
|
t.true(html.includes('<div><p>The answer is 42</p></div>'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -29,6 +29,11 @@ test(async t => {
|
||||||
t.true(html.includes('<div><h1>I can haz meta tags</h1></div>'))
|
t.true(html.includes('<div><h1>I can haz meta tags</h1></div>'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test(async t => {
|
||||||
|
const html = await render('/async-props')
|
||||||
|
t.true(html.includes('<p>Diego Milito</p>'))
|
||||||
|
})
|
||||||
|
|
||||||
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