()
| 28 | } |
| 29 | |
| 30 | const runTests = () => { |
| 31 | it('should render with correct asPath with /_next/data /index requested', async () => { |
| 32 | stdout = '' |
| 33 | const path = `/_next/data/${buildId}/index.json` |
| 34 | await renderViaHTTP(appPort, path) |
| 35 | await waitFor(1000) |
| 36 | const data = await renderViaHTTP(appPort, path) |
| 37 | |
| 38 | expect(JSON.parse(data).pageProps).toEqual({ |
| 39 | hello: 'world', |
| 40 | }) |
| 41 | |
| 42 | await check(() => stdout, /asPath/) |
| 43 | const asPath = stdout.split('asPath: ').pop().split('\n').shift() |
| 44 | expect(asPath).toBe('/') |
| 45 | }) |
| 46 | |
| 47 | it('should render with correct asPath with / requested', async () => { |
| 48 | await checkAsPath('/', '/') |
| 49 | }) |
| 50 | |
| 51 | it('should render with correct asPath with /another/index requested', async () => { |
| 52 | await checkAsPath('/another/index', '/another/index') |
| 53 | }) |
| 54 | |
| 55 | it('should render with correct asPath with /_next/data /another/index requested', async () => { |
| 56 | stdout = '' |
| 57 | const path = `/_next/data/${buildId}/another/index.json` |
| 58 | await renderViaHTTP(appPort, path) |
| 59 | await waitFor(1000) |
| 60 | const data = await renderViaHTTP(appPort, path) |
| 61 | |
| 62 | expect(JSON.parse(data).pageProps).toEqual({ |
| 63 | hello: 'world', |
| 64 | }) |
| 65 | |
| 66 | await check(() => stdout, /asPath/) |
| 67 | const asPath = stdout.split('asPath: ').pop().split('\n').shift() |
| 68 | expect(asPath).toBe('/another/index') |
| 69 | }) |
| 70 | } |
| 71 | |
| 72 | describe('Revalidate asPath Normalizing', () => { |
| 73 | ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( |
no test coverage detected