Skip to content

Commit

Permalink
Fix buildId being escaped breaking test with certain build ids (#10728)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 28, 2020
1 parent 0ff41da commit 5b5d72b
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions test/integration/getserversideprops/test/index.test.js
Expand Up @@ -209,21 +209,15 @@ const runTests = (dev = false) => {
expect(JSON.parse(query)).toEqual({ path: ['first'] })

const data = JSON.parse(
await renderViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/catchall/first.json`
)
await renderViaHTTP(appPort, `/_next/data/${buildId}/catchall/first.json`)
)

expect(data.pageProps.params).toEqual({ path: ['first'] })
})

it('should return data correctly', async () => {
const data = JSON.parse(
await renderViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/something.json`
)
await renderViaHTTP(appPort, `/_next/data/${buildId}/something.json`)
)
expect(data.pageProps.world).toBe('world')
})
Expand All @@ -232,18 +226,15 @@ const runTests = (dev = false) => {
const data = JSON.parse(
await renderViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/something.json?another=thing`
`/_next/data/${buildId}/something.json?another=thing`
)
)
expect(data.pageProps.query.another).toBe('thing')
})

it('should return data correctly for dynamic page', async () => {
const data = JSON.parse(
await renderViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/blog/post-1.json`
)
await renderViaHTTP(appPort, `/_next/data/${buildId}/blog/post-1.json`)
)
expect(data.pageProps.post).toBe('post-1')
})
Expand Down Expand Up @@ -389,7 +380,7 @@ const runTests = (dev = false) => {
it('should set no-cache, no-store, must-revalidate header', async () => {
const res = await fetchViaHTTP(
appPort,
`/_next/data/${escapeRegex(buildId)}/something.json`
`/_next/data/${buildId}/something.json`
)
expect(res.headers.get('cache-control')).toContain('no-cache')
})
Expand Down

0 comments on commit 5b5d72b

Please sign in to comment.