Skip to content

Commit

Permalink
Test Query String with + Sign (#10186)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Jan 21, 2020
1 parent bea488f commit 4bd6a53
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/integration/query-with-encoding/pages/plus.js
@@ -0,0 +1,15 @@
import Link from 'next/link'

const Another = () => (
<div>
<Link href="/?another=hello%2B">
<a id="hello-plus">Hello +</a>
</Link>
<br />
<Link href={{ pathname: '/', query: { complex: 'yes+' } }}>
<a id="hello-complex">Hello Complex</a>
</Link>
</div>
)

export default Another
53 changes: 53 additions & 0 deletions test/integration/query-with-encoding/test/index.test.js
Expand Up @@ -190,4 +190,57 @@ describe('Query String with Encoding', () => {
}
})
})

describe('plus', () => {
it('should have correct query on SSR', async () => {
const browser = await webdriver(appPort, '/?test=abc%2B')
try {
const text = await browser.elementByCss('#query-content').text()
expect(text).toBe('{"test":"abc+"}')
} finally {
await browser.close()
}
})

it('should have correct query on Router#push', async () => {
const browser = await webdriver(appPort, '/')
try {
await waitFor(2000)
await browser.eval(
`window.next.router.push({pathname:'/',query:{abc:'def+'}})`
)
await waitFor(1000)
const text = await browser.elementByCss('#query-content').text()
expect(text).toBe('{"abc":"def+"}')
} finally {
await browser.close()
}
})

it('should have correct query on simple client-side <Link>', async () => {
const browser = await webdriver(appPort, '/plus')
try {
await waitFor(2000)
await browser.elementByCss('#hello-plus').click()
await waitFor(1000)
const text = await browser.elementByCss('#query-content').text()
expect(text).toBe('{"another":"hello+"}')
} finally {
await browser.close()
}
})

it('should have correct query on complex client-side <Link>', async () => {
const browser = await webdriver(appPort, '/plus')
try {
await waitFor(2000)
await browser.elementByCss('#hello-complex').click()
await waitFor(1000)
const text = await browser.elementByCss('#query-content').text()
expect(text).toBe('{"complex":"yes+"}')
} finally {
await browser.close()
}
})
})
})

0 comments on commit 4bd6a53

Please sign in to comment.