Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkmcadoo committed Dec 8, 2021
1 parent 2850016 commit 1968ff7
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
24 changes: 22 additions & 2 deletions scripts/actions/__tests__/__snapshots__/serialize-mdx.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ exports[`serialize Icon inline with text to HTML 1`] = `
exports[`serializes Button to html 1`] = `
"
<div data-type=\\"component\\" data-component=\\"Button\\" data-props=\\"W3sidHlwZSI6Im1keEF0dHJpYnV0ZSIsIm5hbWUiOiJ2YXJpYW50IiwidmFsdWUiOiJwcmltYXJ5In1d\\">
<div data-type=\\"component\\" data-component=\\"Button\\" data-props=\\"W3sidHlwZSI6Im1keEF0dHJpYnV0ZSIsIm5hbWUiOiJ2YXJpYW50IiwidmFsdWUiOiJub3JtYWwifV0=\\">
<div data-type=\\"prop\\" data-prop=\\"children\\">
<p>View all C SDK docs</p>
</div>
Expand Down Expand Up @@ -253,7 +253,27 @@ exports[`serializes CollapserGroup to html 1`] = `
exports[`serializes DoNotTranslate to html 1`] = `
"
<div data-type=\\"component\\" data-component=\\"DoNotTranslate\\" class=\\"notranslate\\">
<p>Not all who wander are lost...</p>
<h1>Not all who wander are lost...</h1>
<p>Testing this line too</p>
</div>
"
`;
exports[`serializes DoNotTranslate to html inline 1`] = `
"
<p>This is an <span data-type=\\"component\\" data-component=\\"DoNotTranslate\\" class=\\"notranslate\\">MDX</span> file</p>
"
`;
exports[`serializes DoNotTranslate wrapping a Collapser 1`] = `
"
<div data-type=\\"component\\" data-component=\\"DoNotTranslate\\" class=\\"notranslate\\">
<div data-type=\\"component\\" data-component=\\"Collapser\\" data-props=\\"W3sidHlwZSI6Im1keEF0dHJpYnV0ZSIsIm5hbWUiOiJ0aXRsZSIsInZhbHVlIjoiQ29sbGFwc2UgbWUgeW8ifV0=\\">
<div data-type=\\"prop\\" data-prop=\\"title\\">Collapse me yo</div>
<div data-type=\\"prop\\" data-prop=\\"children\\">
<p>These tests are hard to write docs for</p>
</div>
</div>
</div>
"
`;
Expand Down
20 changes: 18 additions & 2 deletions scripts/actions/__tests__/deserialize-html.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,25 @@ import fs from 'fs';
test('deserializes mdx with DoNotTranslate', async () => {
const input = `
<DoNotTranslate>
Not all who wander are lost...
# Not all who wander are lost...
but some probably are...
</DoNotTranslate>
`;
`;

const mdx = await deserializeHTML(await serializeMDX(input));

expect(mdx).toEqual(input.trim());
});

test('serializes DoNotTranslate wrapping a Collapser', async () => {
const input = `
<DoNotTranslate>
<Collapser title="Collapse me yo">
These tests are hard to write docs for
</Collapser>
</DoNotTranslate>
`;

const mdx = await deserializeHTML(await serializeMDX(input));

Expand Down
25 changes: 24 additions & 1 deletion scripts/actions/__tests__/serialize-mdx.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
import serializeMDX from '../serialize-mdx';
import fs from 'fs';

test('serializes DoNotTranslate wrapping a Collapser', async () => {
const html = await serializeMDX(`
<DoNotTranslate>
<Collapser
title="Collapse me yo"
>
These tests are hard to write docs for
</Collapser>
</DoNotTranslate>
`);

expect(html).toMatchSnapshot();
});

test('serializes DoNotTranslate to html', async () => {
const html = await serializeMDX(`
<DoNotTranslate>
Not all who wander are lost...
# Not all who wander are lost...
Testing this line too
</DoNotTranslate>
`);

expect(html).toMatchSnapshot();
});

test('serializes DoNotTranslate to html inline', async () => {
const html = await serializeMDX(`
This is an <DoNotTranslate>MDX</DoNotTranslate> file
`);

expect(html).toMatchSnapshot();
});

test('serializes Button to html', async () => {
const html = await serializeMDX(`
<Button
Expand Down

0 comments on commit 1968ff7

Please sign in to comment.