Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Query String with + Sign #10186

Merged
merged 4 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/integration/query-with-encoding/pages/plus.js
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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()
}
})
})
})