Skip to content

Commit

Permalink
chore: add dev tests for MDX
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Jun 30, 2022
1 parent 4e4581d commit aa56d34
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 20 deletions.
55 changes: 44 additions & 11 deletions packages/integrations/mdx/test/mdx-component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,58 @@ import { loadFixture } from '../../../astro/test/test-utils.js';

describe('MDX Component', () => {
let fixture;

before(async () => {
fixture = await loadFixture({
root: new URL('./fixtures/mdx-component', import.meta.url),
root: new URL('./fixtures/mdx-component/', import.meta.url),
integrations: [
mdx()
]
});
await fixture.build();
});

it('builds', async () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);
describe('build', () => {
before(async () => {
await fixture.build();
});


it('works', async () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);

const h1 = document.querySelector('h1');
const foo = document.querySelector('#foo');

expect(h1.textContent).to.equal('Hello component!');
expect(foo.textContent).to.equal('bar');
});
})

describe('dev', () => {
let devServer;

before(async () => {
devServer = await fixture.startDevServer();
});

after(async () => {
await devServer.stop();
});

it('works', async () => {
const res = await fixture.fetch('/');

expect(res.status).to.equal(200);

const html = await res.text();
const { document } = parseHTML(html);

const h1 = document.querySelector('h1');
const foo = document.querySelector('#foo');
const h1 = document.querySelector('h1');
const foo = document.querySelector('#foo');

expect(h1.textContent).to.equal('Hello component!');
expect(foo.textContent).to.equal('bar');
});
expect(h1.textContent).to.equal('Hello component!');
expect(foo.textContent).to.equal('bar');
});
})
})
49 changes: 40 additions & 9 deletions packages/integrations/mdx/test/mdx-page.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,52 @@ describe('MDX Page', () => {
let fixture;

before(async () => {
fixture = await loadFixture({
root: new URL('./fixtures/mdx-page', import.meta.url),
fixture = await loadFixture({
root: new URL('./fixtures/mdx-page/', import.meta.url),
integrations: [
mdx()
]
});
await fixture.build();
});

it('builds', async () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);
describe('build', () => {
before(async () => {
await fixture.build();
});


it('works', async () => {
const html = await fixture.readFile('/index.html');
const { document } = parseHTML(html);

const h1 = document.querySelector('h1');
const h1 = document.querySelector('h1');

expect(h1.textContent).to.equal('Hello page!');
});
expect(h1.textContent).to.equal('Hello page!');
});
})

describe('dev', () => {
let devServer;

before(async () => {
devServer = await fixture.startDevServer();
});

after(async () => {
await devServer.stop();
});

it('works', async () => {
const res = await fixture.fetch('/');

expect(res.status).to.equal(200);

const html = await res.text();
const { document } = parseHTML(html);

const h1 = document.querySelector('h1');

expect(h1.textContent).to.equal('Hello page!');
});
})
})

0 comments on commit aa56d34

Please sign in to comment.