diff options
author | 2023-09-24 08:32:03 +0200 | |
---|---|---|
committer | 2023-09-24 08:32:03 +0200 | |
commit | 2365c124645d5067a12987f205cee23a45d1d13d (patch) | |
tree | 9a713c710b443a7593ca467fedf59bc6c1096730 /packages/integrations/cloudflare/test/routesJson.js | |
parent | 4c4ad9d167e8d15ff2c15e3336ede8ca22f646b2 (diff) | |
download | astro-2365c124645d5067a12987f205cee23a45d1d13d.tar.gz astro-2365c124645d5067a12987f205cee23a45d1d13d.tar.zst astro-2365c124645d5067a12987f205cee23a45d1d13d.zip |
fix(cloudflare): added config for _routes.json generation (#8459)
* added config for _routes.json generation
* added changeset
* renamed test file
* updated comments
* Apply suggestions from code review
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* worked on tests
* worked on docs
* worked on docs
* worked on tests
* updated pnpm-lock.yaml
* worked on tests
* moved the _worker.js in cloudflareSpecialFiles statement
---------
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Alexander Niebuhr <alexander@nbhr.io>
Diffstat (limited to 'packages/integrations/cloudflare/test/routesJson.js')
-rw-r--r-- | packages/integrations/cloudflare/test/routesJson.js | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/packages/integrations/cloudflare/test/routesJson.js b/packages/integrations/cloudflare/test/routesJson.js deleted file mode 100644 index 1714dfb89..000000000 --- a/packages/integrations/cloudflare/test/routesJson.js +++ /dev/null @@ -1,78 +0,0 @@ -import { expect } from 'chai'; -import { loadFixture } from './test-utils.js'; - -/** @type {import('./test-utils.js').Fixture} */ -describe('_routes.json generation', () => { - after(() => { - delete process.env.SRC; - }); - - describe('of both functions and static files', () => { - let fixture; - - before(async () => { - process.env.SRC = './src/mixed'; - fixture = await loadFixture({ - root: './fixtures/routesJson/', - }); - await fixture.build(); - }); - - it('creates `include` for functions and `exclude` for static files where needed', async () => { - const _routesJson = await fixture.readFile('/_routes.json'); - const routes = JSON.parse(_routesJson); - - expect(routes).to.deep.equal({ - version: 1, - include: ['/a/*', '/_image'], - exclude: ['/a/', '/a/redirect', '/a/index.html'], - }); - }); - }); - - describe('of only functions', () => { - let fixture; - - before(async () => { - process.env.SRC = './src/dynamicOnly'; - fixture = await loadFixture({ - root: './fixtures/routesJson/', - }); - await fixture.build(); - }); - - it('creates a wildcard `include` and `exclude` only for the redirect', async () => { - const _routesJson = await fixture.readFile('/_routes.json'); - const routes = JSON.parse(_routesJson); - - expect(routes).to.deep.equal({ - version: 1, - include: ['/*'], - exclude: ['/a/redirect'], - }); - }); - }); - - describe('of only static files', () => { - let fixture; - - before(async () => { - process.env.SRC = './src/staticOnly'; - fixture = await loadFixture({ - root: './fixtures/routesJson/', - }); - await fixture.build(); - }); - - it('create only one `include` and `exclude` that are supposed to match nothing', async () => { - const _routesJson = await fixture.readFile('/_routes.json'); - const routes = JSON.parse(_routesJson); - - expect(routes).to.deep.equal({ - version: 1, - include: ['/_image'], - exclude: [], - }); - }); - }); -}); |