Skip to content

Commit

Permalink
chore: add test for astro:route:setup hook
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre committed Jan 8, 2025
1 parent 3caa337 commit 036316a
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions packages/astro/test/units/integrations/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,55 @@ describe('Integration API', () => {
);
});
});

describe('Routes setup hook', () => {
it('should work in dev', async () => {
let routes = [];
const fixture = await createFixture({
'/src/pages/no-prerender.astro': '---\nexport const prerender = false\n---',
'/src/pages/prerender.astro': '---\nexport const prerender = true\n---',
'/src/pages/unknown-prerender.astro': '',
});

await runInContainer(
{
inlineConfig: {
root: fixture.path,
integrations: [
{
name: 'test',
hooks: {
'astro:route:setup': (params) => {
routes.push({
component: params.route.component,
prerender: params.route.prerender,
});
},
},
},
],
},
},
async () => {
routes.sort((a, b) => a.component.localeCompare(b.component));
assert.deepEqual(routes, [
{
component: 'src/pages/no-prerender.astro',
prerender: false,
},
{
component: 'src/pages/prerender.astro',
prerender: true,
},
{
component: 'src/pages/unknown-prerender.astro',
prerender: true,
},
]);
},
);
});
});
});

describe('Astro feature map', function () {
Expand Down

0 comments on commit 036316a

Please sign in to comment.