/
index.test.ts
33 lines (30 loc) · 954 Bytes
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { fetchViaHTTP } from 'next-test-utils'
describe('Edge vs. non-Edge API route priority', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
'pages/api/user/login.js': `
export default async function handler(_, res) {
res.send('from login.js')
}
`,
'pages/api/user/[id].js': `
export const config = {
runtime: 'experimental-edge',
}
export default async function handler() {
return new Response('from [id].js')
}`,
},
dependencies: {},
})
})
afterAll(() => next.destroy())
it('more specific route should match', async () => {
const res = await fetchViaHTTP(next.url, '/api/user/login')
expect(await res.text()).toBe('from login.js')
})
})