Skip to content

Commit

Permalink
new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Jan 22, 2021
1 parent e4a6448 commit 50d28b2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
17 changes: 17 additions & 0 deletions test/integration/client-navigation/pages/nav/shallow-routing.js
Expand Up @@ -27,6 +27,17 @@ export default class extends Component {
Router.push(href, href, { shallow: true })
}

increaseNonShallow() {
const counter = this.getCurrentCounter()
const href = `/nav/shallow-routing?counter=${counter + 1}`
Router.push(href, href, {})
}

gotoNavShallow() {
const href = `/nav`
Router.push(href, href, { shallow: true })
}

render() {
return (
<div className="shallow-routing">
Expand All @@ -44,6 +55,12 @@ export default class extends Component {
<button id="increase" onClick={() => this.increase()}>
Increase
</button>
<button id="increase2" onClick={() => this.increaseNonShallow()}>
Increase Non-Shallow
</button>
<button id="invalidShallow" onClick={() => this.gotoNavShallow()}>
Invalid Shallow Nav
</button>
</div>
)
}
Expand Down
28 changes: 24 additions & 4 deletions test/integration/client-navigation/test/index.test.js
Expand Up @@ -862,12 +862,32 @@ describe('Client Navigation', () => {
)
const scrollPosition = await browser.eval('window.pageYOffset')

const newScrollPosition = await browser
.elementByCss('#increase')
.click()
.eval('window.pageYOffset')
expect(scrollPosition).toBeGreaterThan(3000)

await browser.elementByCss('#increase').click()
await waitFor(500)
const newScrollPosition = await browser.eval('window.pageYOffset')

expect(newScrollPosition).toBe(scrollPosition)

await browser.elementByCss('#increase2').click()
await waitFor(500)
const newScrollPosition2 = await browser.eval('window.pageYOffset')

expect(newScrollPosition2).toBe(0)

await browser.eval(() =>
document.querySelector('#invalidShallow').scrollIntoView()
)
const scrollPositionDown = await browser.eval('window.pageYOffset')

expect(scrollPositionDown).toBeGreaterThan(3000)

await browser.elementByCss('#invalidShallow').click()
await waitFor(500)
const newScrollPosition3 = await browser.eval('window.pageYOffset')

expect(newScrollPosition3).toBe(0)
})
})

Expand Down

0 comments on commit 50d28b2

Please sign in to comment.