Skip to content

Commit

Permalink
test: content component dev and build
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Feb 16, 2023
1 parent 14559f6 commit 90f7764
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions packages/integrations/markdoc/test/content-collections.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,45 @@ describe('Markdoc - Content Collections', () => {
expect(posts).to.not.be.null;
expect(posts.sort()).to.deep.equal([simplePostEntry, withComponentsEntry, withConfigEntry]);
});

it('renders content - simple', async () => {
const res = await fixture.fetch('/content-simple');
const html = await res.text();
const { document } = parseHTML(html);
const h2 = document.querySelector('h2');
expect(h2.textContent).to.equal('Simple post');
const p = document.querySelector('p');
expect(p.textContent).to.equal('This is a simple Markdoc post.');
});

it('renders content - with config', async () => {
const res = await fixture.fetch('/content-with-config');
const html = await res.text();
const { document } = parseHTML(html);
const h2 = document.querySelector('h2');
expect(h2.textContent).to.equal('Post with config');
const marquee = document.querySelector('marquee');
expect(marquee).to.not.be.null;
expect(marquee.textContent).to.equal('Im a marquee!');
});

it('renders content - with components', async () => {
const res = await fixture.fetch('/content-with-components');
const html = await res.text();
const { document } = parseHTML(html);
const h2 = document.querySelector('h2');
expect(h2.textContent).to.equal('Post with components');

// Renders custom shortcode component
const marquee = document.querySelector('marquee');
expect(marquee).to.not.be.null;
expect(marquee.hasAttribute('data-custom-marquee')).to.equal(true);

// Renders Astro Code component
const pre = document.querySelector('pre');
expect(pre).to.not.be.null;
expect(pre.className).to.equal('astro-code');
});
});

describe('build', () => {
Expand All @@ -54,6 +93,42 @@ describe('Markdoc - Content Collections', () => {
expect(posts).to.not.be.null;
expect(posts.sort()).to.deep.equal([simplePostEntry, withComponentsEntry, withConfigEntry]);
});

it('renders content - simple', async () => {
const html = await fixture.readFile('/content-simple/index.html');
const { document } = parseHTML(html);
const h2 = document.querySelector('h2');
expect(h2.textContent).to.equal('Simple post');
const p = document.querySelector('p');
expect(p.textContent).to.equal('This is a simple Markdoc post.');
});

it('renders content - with config', async () => {
const html = await fixture.readFile('/content-with-config/index.html');
const { document } = parseHTML(html);
const h2 = document.querySelector('h2');
expect(h2.textContent).to.equal('Post with config');
const marquee = document.querySelector('marquee');
expect(marquee).to.not.be.null;
expect(marquee.textContent).to.equal('Im a marquee!');
});

it('renders content - with components', async () => {
const html = await fixture.readFile('/content-with-components/index.html');
const { document } = parseHTML(html);
const h2 = document.querySelector('h2');
expect(h2.textContent).to.equal('Post with components');

// Renders custom shortcode component
const marquee = document.querySelector('marquee');
expect(marquee).to.not.be.null;
expect(marquee.hasAttribute('data-custom-marquee')).to.equal(true);

// Renders Astro Code component
const pre = document.querySelector('pre');
expect(pre).to.not.be.null;
expect(pre.className).to.equal('astro-code');
});
});
});

Expand Down

0 comments on commit 90f7764

Please sign in to comment.