Skip to content

Commit

Permalink
Add explicit mode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Feb 27, 2020
1 parent 1b3da84 commit 0c8f35f
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/integration/prerender/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,49 @@ const runTests = (dev = false, looseMode = false) => {
)
})

it('should support prerendered catchall-explicit route (nested)', async () => {
const html = await renderViaHTTP(
appPort,
'/catchall-explicit/another/value'
)
const $ = cheerio.load(html)

expect(
JSON.parse(
cheerio
.load(html)('#__NEXT_DATA__')
.text()
).isFallback
).toBe(false)
expect($('#catchall').text()).toMatch(/Hi.*?another value/)
})

it('should support prerendered catchall-explicit route (single)', async () => {
const html = await renderViaHTTP(appPort, '/catchall-explicit/second')
const $ = cheerio.load(html)

expect(
JSON.parse(
cheerio
.load(html)('#__NEXT_DATA__')
.text()
).isFallback
).toBe(false)
expect($('#catchall').text()).toMatch(/Hi.*?second/)
})

if (!looseMode) {
it('should 404 for a missing catchall explicit route', async () => {
const res = await fetchViaHTTP(
appPort,
'/catchall-explicit/notreturnedinpaths'
)
expect(res.status).toBe(404)
const html = await res.text()
expect(html).toMatch(/This page could not be found/)
})
}

if (dev) {
// TODO: re-enable when this is supported in dev
// it('should show error when rewriting to dynamic SSG page', async () => {
Expand Down

0 comments on commit 0c8f35f

Please sign in to comment.