Commit 8dd8fb8f authored by JJ Kasper's avatar JJ Kasper Committed by Joe Haddad

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

parent 553052f9
...@@ -32,6 +32,10 @@ app.prepare().then(() => { ...@@ -32,6 +32,10 @@ app.prepare().then(() => {
return app.render(req, res, '/dashboard/index') 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) handleNextRequests(req, res)
}) })
......
hello world
\ No newline at end of file
...@@ -45,6 +45,11 @@ describe('Custom Server', () => { ...@@ -45,6 +45,11 @@ describe('Custom Server', () => {
beforeAll(() => startServer()) beforeAll(() => startServer())
afterAll(() => killApp(server)) 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 () => { it('should handle render with undefined query', async () => {
expect(await renderViaHTTP(appPort, '/no-query')).toMatch(/"query":/) expect(await renderViaHTTP(appPort, '/no-query')).toMatch(/"query":/)
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment