MCPcopy
hub / github.com/vercel/next.js / runTests

Function runTests

test/integration/api-catch-all/test/index.test.ts:16–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14let app
15
16function runTests() {
17 it('should return data when catch-all', async () => {
18 const data = await fetchViaHTTP(appPort, '/api/users/1', null, {}).then(
19 (res) => res.ok && res.json()
20 )
21
22 expect(data).toEqual({ slug: ['1'] })
23 })
24
25 it('should return redirect when catch-all with index and trailing slash', async () => {
26 const res = await fetchViaHTTP(appPort, '/api/users/', null, {
27 redirect: 'manual',
28 })
29 expect(res.status).toBe(308)
30 const text = await res.text()
31 console.log('### ', text)
32 expect(text).toEqual('/api/users')
33 })
34
35 it('should return data when catch-all with index and trailing slash', async () => {
36 const data = await fetchViaHTTP(appPort, '/api/users/', null, {}).then(
37 (res) => res.ok && res.json()
38 )
39
40 expect(data).toEqual({})
41 })
42
43 it('should return data when catch-all with index and no trailing slash', async () => {
44 const data = await fetchViaHTTP(appPort, '/api/users', null, {}).then(
45 (res) => res.ok && res.json()
46 )
47
48 expect(data).toEqual({})
49 })
50}
51
52describe('API routes', () => {
53 describe('dev support', () => {

Callers 1

index.test.tsFile · 0.70

Calls 7

fetchViaHTTPFunction · 0.90
thenMethod · 0.80
textMethod · 0.65
itFunction · 0.50
expectFunction · 0.50
jsonMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected