summaryrefslogtreecommitdiff
path: root/packages/integrations/cloudflare/test/function-per-route.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/cloudflare/test/function-per-route.test.js')
-rw-r--r--packages/integrations/cloudflare/test/function-per-route.test.js45
1 files changed, 21 insertions, 24 deletions
diff --git a/packages/integrations/cloudflare/test/function-per-route.test.js b/packages/integrations/cloudflare/test/function-per-route.test.js
index f0287c717..19cbfde39 100644
--- a/packages/integrations/cloudflare/test/function-per-route.test.js
+++ b/packages/integrations/cloudflare/test/function-per-route.test.js
@@ -1,36 +1,33 @@
-import { loadFixture } from './test-utils.js';
import { expect } from 'chai';
+import { existsSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { astroCli } from './_test-utils.js';
-/** @type {import('./test-utils.js').Fixture} */
-describe('Cloudflare SSR functionPerRoute', () => {
- /** @type {import('./test-utils').Fixture} */
- let fixture;
+const root = new URL('./fixtures/function-per-route/', import.meta.url);
+describe('Function per Route', () => {
before(async () => {
- fixture = await loadFixture({
- root: './fixtures/function-per-route/',
- });
- await fixture.build();
+ await astroCli(fileURLToPath(root), 'build');
});
- after(() => {
- fixture?.clean();
+ it('generates functions folder inside the project root', () => {
+ const testURL = new URL('functions', root);
+ expect(existsSync(fileURLToPath(testURL))).to.be.true;
});
- 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 functions bundles for each page', () => {
+ expect(existsSync(fileURLToPath(new URL('functions/index.js', root)))).to.be.true;
+ expect(existsSync(fileURLToPath(new URL('functions/blog/cool.js', root)))).to.be.true;
+ expect(existsSync(fileURLToPath(new URL('functions/blog/[post].js', root)))).to.be.true;
+ expect(existsSync(fileURLToPath(new URL('functions/[person]/[car].js', root)))).to.be.true;
+ expect(existsSync(fileURLToPath(new URL('functions/files/[[path]].js', root)))).to.be.true;
+ expect(existsSync(fileURLToPath(new URL('functions/[language]/files/[[path]].js', root)))).to.be.true;
+ expect(existsSync(fileURLToPath(new URL('functions/trpc/[trpc].js', root)))).to.be.true;
+ expect(existsSync(fileURLToPath(new URL('functions/javascript.js', root)))).to.be.true;
+ expect(existsSync(fileURLToPath(new URL('functions/test.json.js', root)))).to.be.true;
});
- it('generates pre-rendered files', async () => {
- expect(await fixture.pathExists('./prerender/index.html')).to.be.true;
+ it('generates html files for pre-rendered routes', () => {
+ expect(existsSync(fileURLToPath(new URL('dist/prerender/index.html', root)))).to.be.true;
});
});