2023-06-30 09:09:21 +00:00
|
|
|
import { loadFixture } from './test-utils.js';
|
|
|
|
import { expect } from 'chai';
|
|
|
|
|
2023-08-17 21:40:28 +00:00
|
|
|
/** @type {import('./test-utils.js').Fixture} */
|
|
|
|
describe('Cloudflare SSR functionPerRoute', () => {
|
2023-09-22 14:58:00 +00:00
|
|
|
/** @type {import('./test-utils').Fixture} */
|
2023-06-30 09:09:21 +00:00
|
|
|
let fixture;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({
|
2023-08-17 21:40:28 +00:00
|
|
|
root: './fixtures/function-per-route/',
|
2023-06-30 09:09:21 +00:00
|
|
|
});
|
|
|
|
await fixture.build();
|
|
|
|
});
|
|
|
|
|
|
|
|
after(() => {
|
2023-09-22 14:58:00 +00:00
|
|
|
fixture?.clean();
|
2023-06-30 09:09:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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;
|
2023-07-17 13:12:41 +00:00
|
|
|
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;
|
2023-06-30 09:09:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('generates pre-rendered files', async () => {
|
|
|
|
expect(await fixture.pathExists('./prerender/index.html')).to.be.true;
|
|
|
|
});
|
|
|
|
});
|