0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/mdx/test/mdx-optimize.test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.7 KiB
JavaScript
Raw Normal View History

2024-01-31 03:37:34 -05:00
import * as assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { parseHTML } from 'linkedom';
import { loadFixture } from '../../../astro/test/test-utils.js';
const FIXTURE_ROOT = new URL('./fixtures/mdx-optimize/', import.meta.url);
describe('MDX optimize', () => {
let fixture;
before(async () => {
fixture = await loadFixture({
root: FIXTURE_ROOT,
});
await fixture.build();
});
it('renders an MDX page fine', async () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);
2024-01-31 03:37:34 -05:00
assert.equal(document.querySelector('h1').textContent.includes('MDX page'), true);
assert.equal(
document.querySelector('p').textContent.includes('I once heard a very inspirational quote:'),
true
);
const blockquote = document.querySelector('blockquote.custom-blockquote');
2024-01-31 03:37:34 -05:00
assert.notEqual(blockquote, null);
assert.equal(blockquote.textContent.includes('I like pancakes'), true);
const code = document.querySelector('pre.astro-code');
2024-01-31 03:37:34 -05:00
assert.notEqual(code, null);
assert.equal(code.textContent.includes(`const pancakes = 'yummy'`), true);
});
it('renders an Astro page that imports MDX fine', async () => {
const html = await fixture.readFile('/import/index.html');
const { document } = parseHTML(html);
2024-01-31 03:37:34 -05:00
assert.equal(document.querySelector('h1').textContent.includes('Astro page'), true);
assert.equal(
document.querySelector('p').textContent.includes('I once heard a very inspirational quote:'),
true
);
const blockquote = document.querySelector('blockquote.custom-blockquote');
2024-01-31 03:37:34 -05:00
assert.notEqual(blockquote, null);
assert.equal(blockquote.textContent.includes('I like pancakes'), true);
});
});