()
| 14 | let app |
| 15 | |
| 16 | function 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 | |
| 52 | describe('API routes', () => { |
| 53 | describe('dev support', () => { |
no test coverage detected