summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/test/dynamic-route.test.js
blob: bc9335bfe75c57206afc8f1e0d117dfa25d2d73a (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
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\/\*/);
	});
});