diff options
author | 2023-08-10 05:04:09 +0200 | |
---|---|---|
committer | 2023-08-10 04:04:09 +0100 | |
commit | ea30a9d4f2d7a12345869e971f3051cf803dbe74 (patch) | |
tree | 566148c677c23522a31a8804f04629b25b915a1a /packages/integrations/cloudflare/test/prerender.test.js | |
parent | 9cb32e2a5fd4857992443297ffd0c6e7d88b9ce0 (diff) | |
download | astro-ea30a9d4f2d7a12345869e971f3051cf803dbe74.tar.gz astro-ea30a9d4f2d7a12345869e971f3051cf803dbe74.tar.zst astro-ea30a9d4f2d7a12345869e971f3051cf803dbe74.zip |
more efficient _routes.json for cloudflare integration (#7846)
* more efficient _routes.json for cloudflare integration
* added tests
* updated pnpm-lock.yaml
* added changeset
* cleaned up test
* fix: convert window path separators
* updated docs
* handle more cases
* Apply suggestions from code review
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
* incorporate feedback from code review
* used other pnpm version
* better fallback for empty include array
* adjust test case to changed fallback for empty include array
* updated docs
---------
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Diffstat (limited to 'packages/integrations/cloudflare/test/prerender.test.js')
-rw-r--r-- | packages/integrations/cloudflare/test/prerender.test.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/packages/integrations/cloudflare/test/prerender.test.js b/packages/integrations/cloudflare/test/prerender.test.js index 847bd950a..fe0721f27 100644 --- a/packages/integrations/cloudflare/test/prerender.test.js +++ b/packages/integrations/cloudflare/test/prerender.test.js @@ -18,13 +18,14 @@ describe('Prerendering', () => { fixture.clean(); }); - it('includes prerendered routes in the routes.json config', async () => { - const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json')).exclude.map((r) => - r.replace(/\\/g, '/') - ); - const expectedExcludedRoutes = ['/_worker.js', '/one/index.html', '/one/']; + it('includes non prerendered routes in the routes.json config', async () => { + const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json')); - expect(foundRoutes.every((element) => expectedExcludedRoutes.includes(element))).to.be.true; + expect(foundRoutes).to.deep.equal({ + version: 1, + include: ['/'], + exclude: [], + }); }); }); @@ -45,12 +46,13 @@ describe('Hybrid rendering', () => { delete process.env.PRERENDER; }); - it('includes prerendered routes in the routes.json config', async () => { - const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json')).exclude.map((r) => - r.replace(/\\/g, '/') - ); - const expectedExcludedRoutes = ['/_worker.js', '/index.html', '/']; + it('includes non prerendered routes in the routes.json config', async () => { + const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json')); - expect(foundRoutes.every((element) => expectedExcludedRoutes.includes(element))).to.be.true; + expect(foundRoutes).to.deep.equal({ + version: 1, + include: ['/one'], + exclude: [], + }); }); }); |