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