Commit 66a03bf1 authored by JJ Kasper's avatar JJ Kasper Committed by Joe Haddad

Add test for trailing slash on API route (#7851)

parent bd7a85e2
...@@ -55,7 +55,7 @@ function runTests (serverless = false) { ...@@ -55,7 +55,7 @@ function runTests (serverless = false) {
expect(data).toEqual([{ title: 'Nextjs' }]) expect(data).toEqual([{ title: 'Nextjs' }])
}) })
it('shuld return error with invalid JSON', async () => { it('should return error with invalid JSON', async () => {
const data = await fetchViaHTTP(appPort, '/api/parse', null, { const data = await fetchViaHTTP(appPort, '/api/parse', null, {
method: 'POST', method: 'POST',
headers: { headers: {
......
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
findPort, findPort,
nextBuild, nextBuild,
nextStart, nextStart,
fetchViaHTTP,
renderViaHTTP renderViaHTTP
} from 'next-test-utils' } from 'next-test-utils'
import fetch from 'node-fetch' import fetch from 'node-fetch'
...@@ -144,6 +145,11 @@ describe('Serverless', () => { ...@@ -144,6 +145,11 @@ describe('Serverless', () => {
expect(post).toBe('post-1') expect(post).toBe('post-1')
}) })
it('should 404 on API request with trailing slash', async () => {
const res = await fetchViaHTTP(appPort, '/api/hello/')
expect(res.status).toBe(404)
})
describe('With basic usage', () => { describe('With basic usage', () => {
it('should allow etag header support', async () => { it('should allow etag header support', async () => {
const url = `http://localhost:${appPort}/` const url = `http://localhost:${appPort}/`
......
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