summaryrefslogtreecommitdiff
path: root/packages/integrations/markdoc/test/variables.test.js
blob: 90d5fe27632087e832755ba0e120bb39c19f6e88 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { parseHTML } from 'linkedom';
import { expect } from 'chai';
import { loadFixture } from '../../../astro/test/test-utils.js';
import markdoc from '../dist/index.js';

const root = new URL('./fixtures/variables/', import.meta.url);

describe('Markdoc - Variables', () => {
	let baseFixture;

	before(async () => {
		baseFixture = await loadFixture({
			root,
			integrations: [markdoc()],
		});
	});

	describe('dev', () => {
		let devServer;

		before(async () => {
			devServer = await baseFixture.startDevServer();
		});

		after(async () => {
			await devServer.stop();
		});

		it('has expected entry properties', async () => {
			const res = await baseFixture.fetch('/');
			const html = await res.text();
			const { document } = parseHTML(html);
			expect(document.querySelector('h1')?.textContent).to.equal('Processed by schema: Test entry');
			expect(document.getElementById('id')?.textContent?.trim()).to.equal('id: entry.mdoc');
			expect(document.getElementById('slug')?.textContent?.trim()).to.equal('slug: entry');
			expect(document.getElementById('collection')?.textContent?.trim()).to.equal(
				'collection: blog'
			);
		});
	});

	describe('build', () => {
		before(async () => {
			await baseFixture.build();
		});

		it('has expected entry properties', async () => {
			const html = await baseFixture.readFile('/index.html');
			const { document } = parseHTML(html);
			expect(document.querySelector('h1')?.textContent).to.equal('Processed by schema: Test entry');
			expect(document.getElementById('id')?.textContent?.trim()).to.equal('id: entry.mdoc');
			expect(document.getElementById('slug')?.textContent?.trim()).to.equal('slug: entry');
			expect(document.getElementById('collection')?.textContent?.trim()).to.equal(
				'collection: blog'
			);
		});
	});
});