mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Added the test app for static export.
This commit is contained in:
parent
450277f294
commit
e8ff53f519
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -12,4 +12,6 @@ npm-debug.log
|
|||
.nyc_output
|
||||
coverage
|
||||
|
||||
# test output
|
||||
test/**/.out
|
||||
.DS_Store
|
||||
|
|
12
test/integration/static/next.config.js
Normal file
12
test/integration/static/next.config.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
module.exports = {
|
||||
exportPathMap: function () {
|
||||
return {
|
||||
'/': { page: '/' },
|
||||
'/about': { page: '/about' },
|
||||
'/counter': { page: '/counter' },
|
||||
'/dynamic': { page: '/dynamic', query: { text: 'cool dynamic text' } },
|
||||
'/dynamic/one': { page: '/dynamic', query: { text: 'next export is nice' } },
|
||||
'/dynamic/two': { page: '/dynamic', query: { text: 'zeit is awesome' } }
|
||||
}
|
||||
}
|
||||
}
|
12
test/integration/static/pages/about.js
Normal file
12
test/integration/static/pages/about.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import Link from 'next/link'
|
||||
|
||||
export default () => (
|
||||
<div id='about-page'>
|
||||
<div>
|
||||
<Link href='/'>
|
||||
<a>Go Back</a>
|
||||
</Link>
|
||||
</div>
|
||||
<p>This is the About page</p>
|
||||
</div>
|
||||
)
|
33
test/integration/static/pages/counter.js
Normal file
33
test/integration/static/pages/counter.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import React from 'react'
|
||||
import Link from 'next/link'
|
||||
|
||||
export default class Counter extends React.Component {
|
||||
constructor (...args) {
|
||||
super(...args)
|
||||
this.state = { count: 0 }
|
||||
}
|
||||
|
||||
increaseCounter () {
|
||||
const { count } = this.state
|
||||
this.setState({ count: count + 1 })
|
||||
}
|
||||
|
||||
render () {
|
||||
const { count } = this.state
|
||||
return (
|
||||
<div id='counter-page'>
|
||||
<div>
|
||||
<Link href='/'>
|
||||
<a>Go Back</a>
|
||||
</Link>
|
||||
</div>
|
||||
<p>Counter: {count}</p>
|
||||
<button
|
||||
onClick={() => this.increaseCounter()}
|
||||
>
|
||||
Increase
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
18
test/integration/static/pages/dynamic.js
Normal file
18
test/integration/static/pages/dynamic.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
import Link from 'next/link'
|
||||
|
||||
const DynamicPage = ({ text }) => (
|
||||
<div id='about-page'>
|
||||
<div>
|
||||
<Link href='/'>
|
||||
<a>Go Back</a>
|
||||
</Link>
|
||||
</div>
|
||||
<p>{ text }</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
DynamicPage.getInitialProps = ({ query }) => {
|
||||
return { text: query.text }
|
||||
}
|
||||
|
||||
export default DynamicPage
|
53
test/integration/static/pages/index.js
Normal file
53
test/integration/static/pages/index.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
import Link from 'next/link'
|
||||
import Router from 'next/router'
|
||||
|
||||
function routeToAbout (e) {
|
||||
e.preventDefault()
|
||||
Router.push('/about')
|
||||
}
|
||||
|
||||
export default () => (
|
||||
<div id='home-page'>
|
||||
<div>
|
||||
<Link href='/about' id='about-via-link'>
|
||||
<a>About via Link</a>
|
||||
</Link>
|
||||
<a
|
||||
href='#'
|
||||
onClick={routeToAbout}
|
||||
id='about-via-router'
|
||||
>
|
||||
About via Router
|
||||
</a>
|
||||
<Link href='/counter' id='counter'>
|
||||
<a>Counter</a>
|
||||
</Link>
|
||||
<Link
|
||||
href='/dynamic?text=cool+dynamic+text'
|
||||
id='get-initial-props'
|
||||
>
|
||||
<a>getInitialProps</a>
|
||||
</Link>
|
||||
<Link
|
||||
href='/dynamic?text=next+export+is+nice'
|
||||
as='/dynamic/one'
|
||||
id='dynamic-1'
|
||||
>
|
||||
<a>Dynamic 1</a>
|
||||
</Link>
|
||||
<Link
|
||||
href='/dynamic?text=zeit+is+awesome'
|
||||
as='/dynamic/two'
|
||||
id='dynamic-2'
|
||||
>
|
||||
<a>Dynamic 2</a>
|
||||
</Link>
|
||||
</div>
|
||||
<p>This is the home page</p>
|
||||
<style jsx>{`
|
||||
a {
|
||||
margin: 0 10px 0 0;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
)
|
Loading…
Reference in a new issue