Skip to content

Commit 436e3c1

Browse files
author
Adam Luotonen
committed
markdown tests
1 parent 1f477d6 commit 436e3c1

File tree

9 files changed

+230
-246
lines changed

9 files changed

+230
-246
lines changed

packages/abstract-document/src/abstract-document/__tests__/markdown.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("markdown", () => {
2323
].forEach((item) => {
2424
test(item.name, async () => {
2525
const abstractDoc = render(item.abstractDocJsx);
26-
expect(abstractDoc).toEqual(item.expectedMarkdown);
26+
expect(abstractDoc.children[0]).toEqual(item.expectedMarkdown);
2727
});
2828
});
2929
});

packages/abstract-document/src/abstract-document/__tests__/test-markdown/markdown-bold-italic.tsx

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,25 @@ import { Markdown } from "../../../abstract-document-jsx/index.js";
55
export const testMarkdownBoldItalic: ExportTestDef = {
66
name: "Markdown bold italic",
77
abstractDocJsx: <Markdown text="***Italic and Bold***" />,
8-
expectedMarkdown: [
9-
{
10-
children: [
11-
{
12-
nestedStyleNames: ["Strong", "Emphasis"],
13-
styleName: "Emphasis",
14-
text: "Italic and Bold",
15-
textProperties: {},
16-
type: "TextRun",
17-
},
18-
],
19-
numbering: undefined,
20-
style: {
21-
alignment: undefined,
22-
margins: { bottom: 0, left: 0, right: 0, top: 0 },
23-
position: "relative",
24-
textStyle: { type: "TextStyle" },
25-
type: "ParagraphStyle",
8+
expectedMarkdown: {
9+
children: [
10+
{
11+
nestedStyleNames: ["Strong", "Emphasis"],
12+
styleName: "Emphasis",
13+
text: "Italic and Bold",
14+
textProperties: {},
15+
type: "TextRun",
2616
},
27-
styleName: "",
28-
type: "Paragraph",
17+
],
18+
numbering: undefined,
19+
style: {
20+
alignment: undefined,
21+
margins: { bottom: 0, left: 0, right: 0, top: 0 },
22+
position: "relative",
23+
textStyle: { type: "TextStyle" },
24+
type: "ParagraphStyle",
2925
},
30-
],
26+
styleName: "",
27+
type: "Paragraph",
28+
},
3129
};

packages/abstract-document/src/abstract-document/__tests__/test-markdown/markdown-bold.tsx

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,25 @@ import { Markdown } from "../../../abstract-document-jsx/index.js";
55
export const testMarkdownBold: ExportTestDef = {
66
name: "Markdown bold",
77
abstractDocJsx: <Markdown text="**Bold**" />,
8-
expectedMarkdown: [
9-
{
10-
children: [
11-
{
12-
nestedStyleNames: ["Strong"],
13-
styleName: "Strong",
14-
text: "Bold",
15-
textProperties: {},
16-
type: "TextRun",
17-
},
18-
],
19-
numbering: undefined,
20-
style: {
21-
alignment: undefined,
22-
margins: { bottom: 0, left: 0, right: 0, top: 0 },
23-
position: "relative",
24-
textStyle: { type: "TextStyle" },
25-
type: "ParagraphStyle",
8+
expectedMarkdown: {
9+
children: [
10+
{
11+
nestedStyleNames: ["Strong"],
12+
styleName: "Strong",
13+
text: "Bold",
14+
textProperties: {},
15+
type: "TextRun",
2616
},
27-
styleName: "",
28-
type: "Paragraph",
17+
],
18+
numbering: undefined,
19+
style: {
20+
alignment: undefined,
21+
margins: { bottom: 0, left: 0, right: 0, top: 0 },
22+
position: "relative",
23+
textStyle: { type: "TextStyle" },
24+
type: "ParagraphStyle",
2925
},
30-
],
26+
styleName: "",
27+
type: "Paragraph",
28+
},
3129
};

packages/abstract-document/src/abstract-document/__tests__/test-markdown/markdown-empty-keepTogether.tsx

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,48 @@ import { Markdown, render } from "../../../abstract-document-jsx/index.js";
55
export const testEmptyKeepTogether: ExportTestDef = {
66
name: "Markdown empty keepTogether",
77
abstractDocJsx: <Markdown text="test" keepTogetherSections={true} />,
8-
expectedMarkdown: [
9-
{
10-
children: [
11-
{
12-
children: [
13-
{
14-
nestedStyleNames: [],
15-
styleName: undefined,
16-
text: "test",
17-
textProperties: {},
18-
type: "TextRun",
19-
},
20-
],
21-
numbering: undefined,
22-
style: {
23-
alignment: undefined,
24-
margins: {
25-
bottom: 0,
26-
left: 0,
27-
right: 0,
28-
top: 0,
29-
},
30-
position: "relative",
31-
textStyle: {
32-
type: "TextStyle",
33-
},
34-
type: "ParagraphStyle",
8+
expectedMarkdown: {
9+
children: [
10+
{
11+
children: [
12+
{
13+
nestedStyleNames: [],
14+
styleName: undefined,
15+
text: "test",
16+
textProperties: {},
17+
type: "TextRun",
3518
},
36-
styleName: "",
37-
type: "Paragraph",
38-
},
39-
],
40-
keepTogether: true,
41-
style: {
42-
margins: {
43-
bottom: 0,
44-
left: 0,
45-
right: 0,
46-
top: 0,
19+
],
20+
numbering: undefined,
21+
style: {
22+
alignment: undefined,
23+
margins: {
24+
bottom: 0,
25+
left: 0,
26+
right: 0,
27+
top: 0,
28+
},
29+
position: "relative",
30+
textStyle: {
31+
type: "TextStyle",
32+
},
33+
type: "ParagraphStyle",
4734
},
48-
position: "relative",
49-
type: "GroupStyle",
35+
styleName: "",
36+
type: "Paragraph",
37+
},
38+
],
39+
keepTogether: true,
40+
style: {
41+
margins: {
42+
bottom: 0,
43+
left: 0,
44+
right: 0,
45+
top: 0,
5046
},
51-
type: "Group",
47+
position: "relative",
48+
type: "GroupStyle",
5249
},
53-
],
50+
type: "Group",
51+
},
5452
};

packages/abstract-document/src/abstract-document/__tests__/test-markdown/markdown-header.tsx

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,32 @@ import { Markdown } from "../../../abstract-document-jsx/index.js";
55
export const testMarkdownHeader: ExportTestDef = {
66
name: "Markdown heading 3",
77
abstractDocJsx: <Markdown text="### Heading 3" />,
8-
expectedMarkdown: [
9-
{
10-
children: [
11-
{
12-
nestedStyleNames: ["H3"],
13-
styleName: "H3",
14-
text: "Heading 3",
15-
textProperties: {},
16-
type: "TextRun",
17-
},
18-
],
19-
numbering: undefined,
20-
style: {
21-
alignment: undefined,
22-
margins: {
23-
bottom: 0,
24-
left: 0,
25-
right: 0,
26-
top: 0,
27-
},
28-
position: "relative",
29-
textStyle: {
30-
type: "TextStyle",
31-
},
32-
type: "ParagraphStyle",
8+
expectedMarkdown: {
9+
children: [
10+
{
11+
nestedStyleNames: ["H3"],
12+
styleName: "H3",
13+
text: "Heading 3",
14+
textProperties: {},
15+
type: "TextRun",
3316
},
34-
styleName: "H3",
35-
type: "Paragraph",
17+
],
18+
numbering: undefined,
19+
style: {
20+
alignment: undefined,
21+
margins: {
22+
bottom: 0,
23+
left: 0,
24+
right: 0,
25+
top: 0,
26+
},
27+
position: "relative",
28+
textStyle: {
29+
type: "TextStyle",
30+
},
31+
type: "ParagraphStyle",
3632
},
37-
],
33+
styleName: "H3",
34+
type: "Paragraph",
35+
},
3836
};

packages/abstract-document/src/abstract-document/__tests__/test-markdown/markdown-italic.tsx

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,25 @@ import { Markdown } from "../../../abstract-document-jsx/index.js";
55
export const testMarkdownItalic: ExportTestDef = {
66
name: "Markdown italic",
77
abstractDocJsx: <Markdown text="*Italic*" />,
8-
expectedMarkdown: [
9-
{
10-
children: [
11-
{
12-
nestedStyleNames: ["Emphasis"],
13-
styleName: "Emphasis",
14-
text: "Italic",
15-
textProperties: {},
16-
type: "TextRun",
17-
},
18-
],
19-
numbering: undefined,
20-
style: {
21-
alignment: undefined,
22-
margins: { bottom: 0, left: 0, right: 0, top: 0 },
23-
position: "relative",
24-
textStyle: { type: "TextStyle" },
25-
type: "ParagraphStyle",
8+
expectedMarkdown: {
9+
children: [
10+
{
11+
nestedStyleNames: ["Emphasis"],
12+
styleName: "Emphasis",
13+
text: "Italic",
14+
textProperties: {},
15+
type: "TextRun",
2616
},
27-
styleName: "",
28-
type: "Paragraph",
17+
],
18+
numbering: undefined,
19+
style: {
20+
alignment: undefined,
21+
margins: { bottom: 0, left: 0, right: 0, top: 0 },
22+
position: "relative",
23+
textStyle: { type: "TextStyle" },
24+
type: "ParagraphStyle",
2925
},
30-
],
26+
styleName: "",
27+
type: "Paragraph",
28+
},
3129
};

0 commit comments

Comments
 (0)