summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/test/dynamic-route.test.js
blob: 18d8b8ec284f570f4a3eda0ac076c43aa6ef2466 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { expect } from 'chai';
import { load as cheerioLoad } from 'cheerio';
import { loadFixture } from '../../../astro/test/test-utils.js';
import netlifyAdapter from '../dist/index.js';
import { fileURLToPath } from 'url';

// Asset bundling
describe('Dynamic pages', () => {
	/** @type {import('../../../astro/test/test-utils').Fixture} */
	let fixture;

	before(async () => {
		fixture = await loadFixture({
			root: new URL('./fixtures/dynamic-route/', import.meta.url).toString(),
			experimental: {
				ssr: true,
			},
			adapter: netlifyAdapter({
				dist: new URL('./fixtures/dynamic-route/dist/', import.meta.url),
			}),
			site: `http://example.com`,
			vite: {
				resolve: {
					alias: {
						'@astrojs/netlify/netlify-functions.js': fileURLToPath(
							new URL('../dist/netlify-functions.js', import.meta.url)
						),
					},
				},
			},
		});
		await fixture.build();
	});

	it('Dynamic pages are included in the redirects file', async () => {
		const redir = await fixture.readFile('/_redirects');
		expect(redir).to.match(/\/products\/\*/);
	});
});