From e586d7d704d475afe3373a1de6ae20d504f79d6d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 14:25:23 +0000 Subject: Sync from a8e1c0a7402940e0fc5beef669522b315052df1b --- .../integrations/markdoc/test/variables.test.js | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 packages/integrations/markdoc/test/variables.test.js (limited to 'packages/integrations/markdoc/test/variables.test.js') diff --git a/packages/integrations/markdoc/test/variables.test.js b/packages/integrations/markdoc/test/variables.test.js new file mode 100644 index 000000000..9873afcb7 --- /dev/null +++ b/packages/integrations/markdoc/test/variables.test.js @@ -0,0 +1,55 @@ +import assert from 'node:assert/strict'; +import { after, before, describe, it } from 'node:test'; +import { parseHTML } from 'linkedom'; +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); + 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'); + }); + }); + + describe('build', () => { + before(async () => { + await baseFixture.build(); + }); + + it('has expected entry properties', async () => { + const html = await baseFixture.readFile('/index.html'); + const { document } = parseHTML(html); + 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'); + }); + }); +}); -- cgit v1.2.3