Add test for internal url handling in render (#9396)

This commit is contained in:
JJ Kasper 2019-11-12 19:52:58 -08:00 committed by Joe Haddad
parent 553052f903
commit 8dd8fb8f2a
3 changed files with 10 additions and 0 deletions

View file

@ -32,6 +32,10 @@ app.prepare().then(() => {
return app.render(req, res, '/dashboard/index')
}
if (/static\/hello\.text/.test(req.url)) {
return app.render(req, res, '/static/hello.text')
}
handleNextRequests(req, res)
})

View file

@ -0,0 +1 @@
hello world

View file

@ -45,6 +45,11 @@ describe('Custom Server', () => {
beforeAll(() => startServer())
afterAll(() => killApp(server))
it('should serve internal file from render', async () => {
const data = await renderViaHTTP(appPort, '/static/hello.txt')
expect(data).toMatch(/hello world/)
})
it('should handle render with undefined query', async () => {
expect(await renderViaHTTP(appPort, '/no-query')).toMatch(/"query":/)
})