0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/markdoc/test/variables.test.js
Ben Holmes bef3a75dbc
Markdoc - remove $entry variable (#7244)
* refactor: remove entry prop from `getRenderModule()`

* refactor: remove `$entry` from markdoc

* test: update entry-prop -> variables test

* refactor: unify `getEntryConfigByExt`

* chore: clean up shared content / data get logic

* docs: update `$entry` recommendation

* chore: rename entry-prop -> variables

* chore: changeset

* chore: missed a spot
2023-05-30 16:18:20 -04:00

58 lines
1.8 KiB
JavaScript

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