()
| 18 | let app |
| 19 | |
| 20 | const runTests = () => { |
| 21 | it('should rewrite correctly for path at same level as fallback: false SSR', async () => { |
| 22 | const res = await fetchViaHTTP(appPort, '/hello', undefined, { |
| 23 | redirect: 'manual', |
| 24 | }) |
| 25 | expect(res.status).toBe(200) |
| 26 | |
| 27 | const html = await res.text() |
| 28 | const $ = cheerio.load(html) |
| 29 | |
| 30 | expect($('#another').text()).toBe('another') |
| 31 | expect(JSON.parse($('#query').text())).toEqual({ |
| 32 | path: ['hello'], |
| 33 | }) |
| 34 | }) |
| 35 | |
| 36 | it('should rewrite correctly for path above fallback: false SSR', async () => { |
| 37 | const res = await fetchViaHTTP(appPort, '/hello/world', undefined, { |
| 38 | redirect: 'manual', |
| 39 | }) |
| 40 | expect(res.status).toBe(200) |
| 41 | |
| 42 | const html = await res.text() |
| 43 | const $ = cheerio.load(html) |
| 44 | |
| 45 | expect($('#another').text()).toBe('another') |
| 46 | expect(JSON.parse($('#query').text())).toEqual({ |
| 47 | path: ['hello', 'world'], |
| 48 | }) |
| 49 | }) |
| 50 | |
| 51 | it('should rewrite correctly for path at same level as fallback: false client', async () => { |
| 52 | const browser = await webdriver(appPort, '/hello') |
| 53 | |
| 54 | expect(await browser.elementByCss('#another').text()).toBe('another') |
| 55 | expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({ |
| 56 | path: ['hello'], |
| 57 | }) |
| 58 | }) |
| 59 | |
| 60 | it('should rewrite correctly for path above fallback: false client', async () => { |
| 61 | const browser = await webdriver(appPort, '/hello/world') |
| 62 | |
| 63 | expect(await browser.elementByCss('#another').text()).toBe('another') |
| 64 | expect(JSON.parse(await browser.elementByCss('#query').text())).toEqual({ |
| 65 | path: ['hello', 'world'], |
| 66 | }) |
| 67 | }) |
| 68 | |
| 69 | it('should not rewrite for path from fallback: false SSR', async () => { |
| 70 | const res = await fetchViaHTTP(appPort, '/first', undefined, { |
| 71 | redirect: 'manual', |
| 72 | }) |
| 73 | expect(res.status).toBe(200) |
| 74 | |
| 75 | const html = await res.text() |
| 76 | const $ = cheerio.load(html) |
| 77 |
no test coverage detected