Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Feb 29, 2020
1 parent 4363e83 commit c081b3d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/integration/preload-viewport/pages/not-de-duped.js
@@ -0,0 +1,11 @@
import Link from 'next/link'

export default () => {
return (
<p>
<Link href="/first" as="/first#different">
<a>to /first</a>
</Link>
</p>
)
}
16 changes: 16 additions & 0 deletions test/integration/preload-viewport/test/index.test.js
Expand Up @@ -228,4 +228,20 @@ describe('Prefetching Links in viewport', () => {
const calledPrefetch = await browser.eval(`window.calledPrefetch`)
expect(calledPrefetch).toBe(false)
})

it('should prefetch with a different asPath for a prefetched page', async () => {
// info: both `/` and `/not-de-duped` ref the `/first` page, which we want
// to see prefetched twice.
const browser = await webdriver(appPort, '/')
await browser.eval(`(function() {
window.calledPrefetch = false
window.next.router.prefetch = function() {
window.calledPrefetch = true
}
window.next.router.push('/not-de-duped')
})()`)
await waitFor(2 * 1000)
const calledPrefetch = await browser.eval(`window.calledPrefetch`)
expect(calledPrefetch).toBe(true)
})
})

0 comments on commit c081b3d

Please sign in to comment.