Skip to content

Commit 90f7764

Browse files
committed
test: content component dev and build
1 parent 14559f6 commit 90f7764

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

packages/integrations/markdoc/test/content-collections.test.js

+75
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,45 @@ describe('Markdoc - Content Collections', () => {
3535
expect(posts).to.not.be.null;
3636
expect(posts.sort()).to.deep.equal([simplePostEntry, withComponentsEntry, withConfigEntry]);
3737
});
38+
39+
it('renders content - simple', async () => {
40+
const res = await fixture.fetch('/content-simple');
41+
const html = await res.text();
42+
const { document } = parseHTML(html);
43+
const h2 = document.querySelector('h2');
44+
expect(h2.textContent).to.equal('Simple post');
45+
const p = document.querySelector('p');
46+
expect(p.textContent).to.equal('This is a simple Markdoc post.');
47+
});
48+
49+
it('renders content - with config', async () => {
50+
const res = await fixture.fetch('/content-with-config');
51+
const html = await res.text();
52+
const { document } = parseHTML(html);
53+
const h2 = document.querySelector('h2');
54+
expect(h2.textContent).to.equal('Post with config');
55+
const marquee = document.querySelector('marquee');
56+
expect(marquee).to.not.be.null;
57+
expect(marquee.textContent).to.equal('Im a marquee!');
58+
});
59+
60+
it('renders content - with components', async () => {
61+
const res = await fixture.fetch('/content-with-components');
62+
const html = await res.text();
63+
const { document } = parseHTML(html);
64+
const h2 = document.querySelector('h2');
65+
expect(h2.textContent).to.equal('Post with components');
66+
67+
// Renders custom shortcode component
68+
const marquee = document.querySelector('marquee');
69+
expect(marquee).to.not.be.null;
70+
expect(marquee.hasAttribute('data-custom-marquee')).to.equal(true);
71+
72+
// Renders Astro Code component
73+
const pre = document.querySelector('pre');
74+
expect(pre).to.not.be.null;
75+
expect(pre.className).to.equal('astro-code');
76+
});
3877
});
3978

4079
describe('build', () => {
@@ -54,6 +93,42 @@ describe('Markdoc - Content Collections', () => {
5493
expect(posts).to.not.be.null;
5594
expect(posts.sort()).to.deep.equal([simplePostEntry, withComponentsEntry, withConfigEntry]);
5695
});
96+
97+
it('renders content - simple', async () => {
98+
const html = await fixture.readFile('/content-simple/index.html');
99+
const { document } = parseHTML(html);
100+
const h2 = document.querySelector('h2');
101+
expect(h2.textContent).to.equal('Simple post');
102+
const p = document.querySelector('p');
103+
expect(p.textContent).to.equal('This is a simple Markdoc post.');
104+
});
105+
106+
it('renders content - with config', async () => {
107+
const html = await fixture.readFile('/content-with-config/index.html');
108+
const { document } = parseHTML(html);
109+
const h2 = document.querySelector('h2');
110+
expect(h2.textContent).to.equal('Post with config');
111+
const marquee = document.querySelector('marquee');
112+
expect(marquee).to.not.be.null;
113+
expect(marquee.textContent).to.equal('Im a marquee!');
114+
});
115+
116+
it('renders content - with components', async () => {
117+
const html = await fixture.readFile('/content-with-components/index.html');
118+
const { document } = parseHTML(html);
119+
const h2 = document.querySelector('h2');
120+
expect(h2.textContent).to.equal('Post with components');
121+
122+
// Renders custom shortcode component
123+
const marquee = document.querySelector('marquee');
124+
expect(marquee).to.not.be.null;
125+
expect(marquee.hasAttribute('data-custom-marquee')).to.equal(true);
126+
127+
// Renders Astro Code component
128+
const pre = document.querySelector('pre');
129+
expect(pre).to.not.be.null;
130+
expect(pre.className).to.equal('astro-code');
131+
});
57132
});
58133
});
59134

0 commit comments

Comments
 (0)