diff --git a/.gitignore b/.gitignore index 1f02e940..ea910653 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ npm-debug.log .nyc_output coverage +# test output +test/**/.out .DS_Store diff --git a/test/integration/static/next.config.js b/test/integration/static/next.config.js new file mode 100644 index 00000000..9a9d08fc --- /dev/null +++ b/test/integration/static/next.config.js @@ -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' } } + } + } +} diff --git a/test/integration/static/pages/about.js b/test/integration/static/pages/about.js new file mode 100644 index 00000000..7ecf1d59 --- /dev/null +++ b/test/integration/static/pages/about.js @@ -0,0 +1,12 @@ +import Link from 'next/link' + +export default () => ( +
+
+ + Go Back + +
+

This is the About page

+
+) diff --git a/test/integration/static/pages/counter.js b/test/integration/static/pages/counter.js new file mode 100644 index 00000000..97f3b8e8 --- /dev/null +++ b/test/integration/static/pages/counter.js @@ -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 ( +
+
+ + Go Back + +
+

Counter: {count}

+ +
+ ) + } +} diff --git a/test/integration/static/pages/dynamic.js b/test/integration/static/pages/dynamic.js new file mode 100644 index 00000000..c733ee15 --- /dev/null +++ b/test/integration/static/pages/dynamic.js @@ -0,0 +1,18 @@ +import Link from 'next/link' + +const DynamicPage = ({ text }) => ( +
+
+ + Go Back + +
+

{ text }

+
+) + +DynamicPage.getInitialProps = ({ query }) => { + return { text: query.text } +} + +export default DynamicPage diff --git a/test/integration/static/pages/index.js b/test/integration/static/pages/index.js new file mode 100644 index 00000000..1d1886a0 --- /dev/null +++ b/test/integration/static/pages/index.js @@ -0,0 +1,53 @@ +import Link from 'next/link' +import Router from 'next/router' + +function routeToAbout (e) { + e.preventDefault() + Router.push('/about') +} + +export default () => ( +
+
+ + About via Link + + + About via Router + + + Counter + + + getInitialProps + + + Dynamic 1 + + + Dynamic 2 + +
+

This is the home page

+ +
+)