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-plus-react.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

50 lines
1.2 KiB
JavaScript

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';
function hookError() {
const error = console.error;
const errors = [];
console.error = function (...args) {
errors.push(args);
};
return () => {
console.error = error;
return errors;
};
}
describe('MDX and React', () => {
let fixture;
let unhook;
before(async () => {
fixture = await loadFixture({
root: new URL('./fixtures/mdx-plus-react/', import.meta.url),
});
unhook = hookError();
await fixture.build();
});
it('can be used in the same project', async () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);
const p = document.querySelector('p');
assert.equal(p.textContent, 'Hello world');
});
it('mdx renders fine', async () => {
const html = await fixture.readFile('/post/index.html');
const { document } = parseHTML(html);
const h = document.querySelector('#testing');
assert.equal(h.textContent, 'Testing');
});
it('does not get a invalid hook call warning', () => {
const errors = unhook();
assert.equal(errors.length === 0, true);
});
});