|
| 1 | +import { nextTestSetup } from 'e2e-utils' |
| 2 | + |
| 3 | +describe('i18n-disallow-multiple-locales', () => { |
| 4 | + const { next } = nextTestSetup({ |
| 5 | + files: __dirname, |
| 6 | + }) |
| 7 | + |
| 8 | + it.each([ |
| 9 | + ['/non-existent'], |
| 10 | + ['/es/non-existent'], |
| 11 | + ['/first/non-existent'], |
| 12 | + ['/es/first/non-existent'], |
| 13 | + ['/first/second/non-existent'], |
| 14 | + ['/es/first/second/non-existent'], |
| 15 | + ])( |
| 16 | + 'should 404 properly for fallback: false non-prerendered %s', |
| 17 | + async (pathname) => { |
| 18 | + const res = await next.fetch(pathname) |
| 19 | + expect(res.status).toBe(404) |
| 20 | + } |
| 21 | + ) |
| 22 | + |
| 23 | + it.each([ |
| 24 | + { urlPath: '/first', page: '/[first]' }, |
| 25 | + { urlPath: '/first/second', page: '/[first]/[second]' }, |
| 26 | + { urlPath: '/first/second/third', page: '/[first]/[second]/[third]' }, |
| 27 | + { |
| 28 | + urlPath: '/first/second/third/fourth', |
| 29 | + page: '/[first]/[second]/[third]/[fourth]', |
| 30 | + }, |
| 31 | + ])( |
| 32 | + 'should render properly for fallback: false prerendered $urlPath', |
| 33 | + async ({ urlPath, page }) => { |
| 34 | + const res = await next.fetch(urlPath) |
| 35 | + expect(res.status).toBe(200) |
| 36 | + expect(await res.text()).toContain(page) |
| 37 | + } |
| 38 | + ) |
| 39 | + |
| 40 | + it('should render properly for fallback: blocking', async () => { |
| 41 | + const res = await next.fetch('/first/second/third/another') |
| 42 | + expect(res.status).toBe(200) |
| 43 | + expect(await res.text()).toContain('/[first]/[second]/[third]/[fourth]') |
| 44 | + }) |
| 45 | +}) |
0 commit comments