0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00
astro/packages/integrations/markdoc/test/variables.test.js
Emanuele Stoppa 062623438b
chore: use biome to sort imports - only test files (#10180)
* chore: use biome to sort imports

* do the sorting

* Update package.json

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>

---------

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
2024-02-21 14:08:19 +00:00

55 lines
1.8 KiB
JavaScript

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');
});
});
});