-
Notifications
You must be signed in to change notification settings - Fork 42
/
shared.base.js
146 lines (130 loc) · 3.71 KB
/
shared.base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React from "react";
import { View } from "react-native";
import { iterator } from "@times-components/test-utils";
import renderTrees, { renderTree } from "@times-components/markup-forest";
import coreRenderers from "../src/markup";
import paragraph from "../fixtures/paragraph.json";
import block from "../fixtures/block.json";
import bold from "../fixtures/bold.json";
import emphasis from "../fixtures/emphasis.json";
import inline from "../fixtures/inline.json";
import image from "../fixtures/image.json";
import italic from "../fixtures/italic.json";
import lineBreak from "../fixtures/break.json";
import script from "../fixtures/script.json";
import strong from "../fixtures/strong.json";
import subscript from "../fixtures/subscript.json";
import subscriptWithFallback from "../fixtures/subscript-fallback.json";
import superscript from "../fixtures/superscript.json";
import superscriptWithFallback from "../fixtures/superscript-fallback.json";
export default renderComponent => {
const tests = [
{
name: "block",
test: () => {
const output = renderComponent(renderTree(block, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "bold",
test: () => {
const output = renderComponent(renderTree(bold, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "break",
test: () => {
const output = renderComponent(renderTree(lineBreak, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "emphasis",
test: () => {
const output = renderComponent(renderTree(emphasis, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "image tag",
test: () => {
const output = renderComponent(
<View>{renderTrees(image, coreRenderers)}</View>
);
expect(output).toMatchSnapshot();
}
},
{
name: "inline",
test: () => {
const output = renderComponent(renderTree(inline, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "italic",
test: () => {
const output = renderComponent(renderTree(italic, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "paragraph",
test: () => {
const output = renderComponent(renderTree(paragraph, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "strong",
test: () => {
const output = renderComponent(renderTree(strong, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "subscript",
test: () => {
const output = renderComponent(renderTree(subscript, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "subscript with fallback",
test: () => {
const output = renderComponent(
renderTree(subscriptWithFallback, coreRenderers)
);
expect(output).toMatchSnapshot();
}
},
{
name: "superscript",
test: () => {
const output = renderComponent(renderTree(superscript, coreRenderers));
expect(output).toMatchSnapshot();
}
},
{
name: "superscript with fallback",
test: () => {
const output = renderComponent(
renderTree(superscriptWithFallback, coreRenderers)
);
expect(output).toMatchSnapshot();
}
},
{
name: "does not render a script tag",
test: () => {
const output = renderComponent(
<View>{renderTrees(script, coreRenderers)}</View>
);
expect(output).toMatchSnapshot();
}
}
];
iterator(tests);
};