Skip to content

Commit

Permalink
test: Add error on malformed URL (#5269)
Browse files Browse the repository at this point in the history
  • Loading branch information
toshi1127 authored and clarkdo committed Mar 19, 2019
1 parent d03a61b commit 8bbb269
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/server/test/middleware/nuxt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,19 @@ describe('server: nuxtMiddleware', () => {
expect(await nuxtMiddleware(req, res, next)).toBe(err)
expect(consola.error).toBeCalledWith(err)
})

test('should return 400 if request is uri error', async () => {
const context = createContext()
const result = { html: 'rendered html' }
context.renderRoute.mockReturnValue(result)
const nuxtMiddleware = createNuxtMiddleware(context)
const { req, res, next } = createServerContext()

const err = Error('URI malformed')
err.name = 'URIError'

await nuxtMiddleware({ ...req, url: 'http://localhost/test/server/%c1%81' }, res, next)

expect(next).toBeCalledWith(err)
})
})

0 comments on commit 8bbb269

Please sign in to comment.