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

Add tests for behaviour mentioned in #1079 (#1084)

This commit is contained in:
Tim Neutkens 2017-02-12 17:46:11 +01:00 committed by Guillermo Rauch
parent 66d97744e9
commit a0453a7b84
2 changed files with 46 additions and 0 deletions

View file

@ -0,0 +1,22 @@
import React from 'react'
import Link from 'next/link'
export default class AsyncProps extends React.Component {
static async getInitialProps ({ query: { id = 0 } }) {
return { id }
}
render () {
return (
<div>
<Link href={`/nav/querystring?id=${parseInt(this.props.id) + 1}`}>
<a id='next-id-link'>Click here</a>
</Link>
<Link href='/nav/querystring'>
<a id='main-page'>Click here</a>
</Link>
<p className={`nav-id-${this.props.id}`}>{this.props.id}</p>
</div>
)
}
}

View file

@ -59,5 +59,29 @@ export default (context) => {
await browser.close()
})
})
describe('with the same page but different querystring', () => {
it('should navigate the page', async () => {
const browser = await webdriver(context.appPort, '/nav/querystring?id=1')
const text = await browser
.elementByCss('#next-id-link').click()
.waitForElementByCss('.nav-id-2')
.elementByCss('p').text()
expect(text).toBe('2')
await browser.close()
})
it('should remove querystring', async () => {
const browser = await webdriver(context.appPort, '/nav/querystring?id=1')
const text = await browser
.elementByCss('#main-page').click()
.waitForElementByCss('.nav-id-0')
.elementByCss('p').text()
expect(text).toBe('0')
await browser.close()
})
})
})
}