()
| 24 | let start |
| 25 | |
| 26 | const runTests = () => { |
| 27 | it('should error when empty headers array is present on header item', async () => { |
| 28 | await writeConfig( |
| 29 | [ |
| 30 | { |
| 31 | source: `/:path*`, |
| 32 | headers: [], |
| 33 | }, |
| 34 | ], |
| 35 | 'headers' |
| 36 | ) |
| 37 | await start() |
| 38 | await retry(() => { |
| 39 | const stderr = getStderr() |
| 40 | expect(stderr).toContain( |
| 41 | '`headers` field cannot be empty for route {"source":"/:path*"' |
| 42 | ) |
| 43 | }) |
| 44 | }) |
| 45 | |
| 46 | it('should error when source and destination length is exceeded', async () => { |
| 47 | await writeConfig( |
| 48 | [ |
| 49 | { |
| 50 | source: `/${Array(4096).join('a')}`, |
| 51 | destination: `/another`, |
| 52 | permanent: false, |
| 53 | }, |
| 54 | { |
| 55 | source: `/`, |
| 56 | destination: `/${Array(4096).join('a')}`, |
| 57 | permanent: false, |
| 58 | }, |
| 59 | ], |
| 60 | 'redirects' |
| 61 | ) |
| 62 | await start() |
| 63 | await retry(() => { |
| 64 | const stderr = getStderr() |
| 65 | expect(stderr).toContain( |
| 66 | '`source` exceeds max built length of 4096 for route {"source":"/aaaaaaaaaaaaaaaaaa' |
| 67 | ) |
| 68 | expect(stderr).toContain( |
| 69 | '`destination` exceeds max built length of 4096 for route {"source":"/","destination":"/aaaa' |
| 70 | ) |
| 71 | }) |
| 72 | }) |
| 73 | |
| 74 | it('should error during next build for invalid redirects', async () => { |
| 75 | await writeConfig( |
| 76 | [ |
| 77 | { |
| 78 | // missing destination |
| 79 | source: '/hello', |
| 80 | permanent: false, |
| 81 | }, |
| 82 | { |
| 83 | // invalid source |
no test coverage detected