| 9 | }) |
| 10 | |
| 11 | function runTests(url) { |
| 12 | describe('page ' + url, () => { |
| 13 | it(`should render the page ${url}`, async () => { |
| 14 | const html = await next.render(url) |
| 15 | expect(html).toMatch(/Hello World/) |
| 16 | }) |
| 17 | |
| 18 | it('should not have JS preload links', async () => { |
| 19 | const $ = await next.render$(url) |
| 20 | expect($('link[rel=preload]').length).toBe(0) |
| 21 | }) |
| 22 | |
| 23 | it('should load scripts with defer in head', async () => { |
| 24 | const $ = await next.render$(url) |
| 25 | expect($('script[async]').length).toBe(0) |
| 26 | expect($('head script[defer]').length).toBeGreaterThan(0) |
| 27 | }) |
| 28 | }) |
| 29 | } |
| 30 | |
| 31 | runTests('/') |
| 32 | runTests('/page1') |