0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/cloudflare/test/prerender.test.js
Nate Moore 39403c32fa
Unflag hybrid output (#7260)
* feat(hybrid): unflag hybrid output

* chore: cleanup rebase errors
2023-06-05 13:19:15 -05:00

57 lines
1.5 KiB
JavaScript

import { loadFixture } from './test-utils.js';
import { expect } from 'chai';
import slash from 'slash';
describe('Prerendering', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
process.env.PRERENDER = true;
fixture = await loadFixture({
root: './fixtures/prerender/',
});
await fixture.build();
});
after(() => {
delete process.env.PRERENDER;
fixture.clean();
});
it('includes prerendered routes in the routes.json config', async () => {
const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json')).exclude.map((r) =>
slash(r)
);
const expectedExcludedRoutes = ['/_worker.js', '/one/index.html', '/one/'];
expect(foundRoutes.every((element) => expectedExcludedRoutes.includes(element))).to.be.true;
});
});
describe('Hybrid rendering', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
process.env.PRERENDER = false;
fixture = await loadFixture({
root: './fixtures/prerender/',
output: 'hybrid',
});
await fixture.build();
});
after(() => {
delete process.env.PRERENDER;
});
it('includes prerendered routes in the routes.json config', async () => {
const foundRoutes = JSON.parse(await fixture.readFile('/_routes.json')).exclude.map((r) =>
slash(r)
);
const expectedExcludedRoutes = ['/_worker.js', '/index.html', '/'];
expect(foundRoutes.every((element) => expectedExcludedRoutes.includes(element))).to.be.true;
});
});