Skip to content

Commit

Permalink
chore: move test to another file for consitency
Browse files Browse the repository at this point in the history
  • Loading branch information
MoustaphaDev committed May 17, 2023
1 parent c408482 commit 3f340a3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 48 deletions.
48 changes: 0 additions & 48 deletions packages/astro/test/ssr-prerender-integrations.test.js

This file was deleted.

45 changes: 45 additions & 0 deletions packages/astro/test/ssr-prerender.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,48 @@ describe('SSR: prerender', () => {
});
});
});

describe('Integrations can hook into the prerendering decision', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;

const testIntegration = {
name: 'test prerendering integration',
hooks: {
['astro:build:setup']({ pages, target }) {
if (target !== 'client') return;
// this page has `export const prerender = true`
pages.get('src/pages/static.astro').route.prerender = false;

// this page does not
pages.get('src/pages/not-prerendered.astro').route.prerender = true;
},
},
};

before(async () => {
fixture = await loadFixture({
root: './fixtures/ssr-prerender/',
output: 'server',
integrations: [testIntegration],
adapter: testAdapter(),
});
await fixture.build();
});

it('An integration can override the prerender flag', async () => {
// test adapter only hosts dynamic routes
// /static is expected to become dynamic
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com/static');
const response = await app.render(request);
expect(response.status).to.equal(200);
});

it('An integration can turn a normal page to a prerendered one', async () => {
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com/not-prerendered');
const response = await app.render(request);
expect(response.status).to.equal(404);
});
});

0 comments on commit 3f340a3

Please sign in to comment.