2024-01-31 05:37:39 -05:00
|
|
|
import assert from 'node:assert/strict';
|
|
|
|
import { after, before, describe, it } from 'node:test';
|
2023-03-21 08:20:23 -05:00
|
|
|
import { parseHTML } from 'linkedom';
|
|
|
|
import { loadFixture } from '../../../astro/test/test-utils.js';
|
|
|
|
import markdoc from '../dist/index.js';
|
|
|
|
|
2023-05-30 15:18:20 -05:00
|
|
|
const root = new URL('./fixtures/variables/', import.meta.url);
|
2023-03-21 08:20:23 -05:00
|
|
|
|
2023-05-30 15:18:20 -05:00
|
|
|
describe('Markdoc - Variables', () => {
|
2023-03-21 08:20:23 -05:00
|
|
|
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);
|
2024-01-31 05:37:39 -05:00
|
|
|
assert.equal(document.querySelector('h1')?.textContent, 'Processed by schema: Test entry');
|
|
|
|
assert.equal(document.getElementById('id')?.textContent?.trim(), 'id: entry.mdoc');
|
|
|
|
assert.equal(document.getElementById('slug')?.textContent?.trim(), 'slug: entry');
|
|
|
|
assert.equal(document.getElementById('collection')?.textContent?.trim(), 'collection: blog');
|
2023-03-21 08:20:23 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('build', () => {
|
|
|
|
before(async () => {
|
|
|
|
await baseFixture.build();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('has expected entry properties', async () => {
|
|
|
|
const html = await baseFixture.readFile('/index.html');
|
|
|
|
const { document } = parseHTML(html);
|
2024-01-31 05:37:39 -05:00
|
|
|
assert.equal(document.querySelector('h1')?.textContent, 'Processed by schema: Test entry');
|
|
|
|
assert.equal(document.getElementById('id')?.textContent?.trim(), 'id: entry.mdoc');
|
|
|
|
assert.equal(document.getElementById('slug')?.textContent?.trim(), 'slug: entry');
|
|
|
|
assert.equal(document.getElementById('collection')?.textContent?.trim(), 'collection: blog');
|
2023-03-21 08:20:23 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|