summaryrefslogtreecommitdiff
path: root/packages/integrations/cloudflare/test/function-per-route.test.js
diff options
context:
space:
mode:
authorGravatar Alexander Niebuhr <alexander@nbhr.io> 2023-08-17 23:40:28 +0200
committerGravatar GitHub <noreply@github.com> 2023-08-17 16:40:28 -0500
commit2540feedb06785d5a20eecc3668849f147d778d4 (patch)
treed673b70a1d934faa1b0df369512a43817a002692 /packages/integrations/cloudflare/test/function-per-route.test.js
parentbbf0b7470bcd8f143d4d7ab8fa169f2bb14a41f0 (diff)
downloadastro-2540feedb06785d5a20eecc3668849f147d778d4.tar.gz
astro-2540feedb06785d5a20eecc3668849f147d778d4.tar.zst
astro-2540feedb06785d5a20eecc3668849f147d778d4.zip
feature(@astrojs/cloudflare): port functionPerRoute (#8078)
* port functionPerRoute to cloudflare * add changeset * port bugfix to next * update changeset * Update packages/astro/src/core/build/generate.ts Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> * update changeset * update README * add TODO comment * Update .changeset/wise-cameras-agree.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/wise-cameras-agree.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/nasty-garlics-listen.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * update README * Update .changeset/wise-cameras-agree.md Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> * Update packages/integrations/cloudflare/README.md Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> --------- Co-authored-by: Emanuele Stoppa <my.burning@gmail.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/cloudflare/test/function-per-route.test.js')
-rw-r--r--packages/integrations/cloudflare/test/function-per-route.test.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/integrations/cloudflare/test/function-per-route.test.js b/packages/integrations/cloudflare/test/function-per-route.test.js
new file mode 100644
index 000000000..d20b0fa7c
--- /dev/null
+++ b/packages/integrations/cloudflare/test/function-per-route.test.js
@@ -0,0 +1,35 @@
+import { loadFixture } from './test-utils.js';
+import { expect } from 'chai';
+
+/** @type {import('./test-utils.js').Fixture} */
+describe('Cloudflare SSR functionPerRoute', () => {
+ let fixture;
+
+ before(async () => {
+ fixture = await loadFixture({
+ root: './fixtures/function-per-route/',
+ });
+ await fixture.build();
+ });
+
+ after(() => {
+ fixture.clean();
+ });
+
+ it('generates functions folders inside the project root, and checks that each page is emitted by astro', async () => {
+ expect(await fixture.pathExists('../functions')).to.be.true;
+ expect(await fixture.pathExists('../functions/index.js')).to.be.true;
+ expect(await fixture.pathExists('../functions/blog/cool.js')).to.be.true;
+ expect(await fixture.pathExists('../functions/blog/[post].js')).to.be.true;
+ expect(await fixture.pathExists('../functions/[person]/[car].js')).to.be.true;
+ expect(await fixture.pathExists('../functions/files/[[path]].js')).to.be.true;
+ expect(await fixture.pathExists('../functions/[language]/files/[[path]].js')).to.be.true;
+ expect(await fixture.pathExists('../functions/trpc/[trpc].js')).to.be.true;
+ expect(await fixture.pathExists('../functions/javascript.js')).to.be.true;
+ expect(await fixture.pathExists('../functions/test.json.js')).to.be.true;
+ });
+
+ it('generates pre-rendered files', async () => {
+ expect(await fixture.pathExists('./prerender/index.html')).to.be.true;
+ });
+});