Skip to content

Commit d290fad

Browse files
Merge pull request #185 from remarkablemark/test/helpers
test: refactor tests and add snapshots
2 parents 08370e4 + 8db1768 commit d290fad

File tree

6 files changed

+609
-562
lines changed

6 files changed

+609
-562
lines changed

test/__snapshots__/attributes-to-props.test.js.snap

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,118 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`attributes to props style parses CSS to JS 1`] = `
3+
exports[`attributesToProps with HTML attribute converts RDFa attributes to React props 1`] = `
4+
Object {
5+
"property": "foo",
6+
"typeof": "bar",
7+
}
8+
`;
9+
10+
exports[`attributesToProps with HTML attribute converts attributes to React props 1`] = `
11+
Object {
12+
"className": "ic",
13+
"htmlFor": "tran",
14+
"httpEquiv": "refresh",
15+
}
16+
`;
17+
18+
exports[`attributesToProps with HTML attribute converts attributes with weird capitalization 1`] = `
19+
Object {
20+
"acceptCharset": "ISO-8859-1",
21+
"data-FOO": "bar",
22+
"formNoValidate": true,
23+
"security": "restricted",
24+
}
25+
`;
26+
27+
exports[`attributesToProps with HTML attribute converts boolean attributes 1`] = `
28+
Object {
29+
"allowFullScreen": true,
30+
"allowpaymentrequest": "",
31+
"async": true,
32+
"autoFocus": true,
33+
"autoPlay": true,
34+
"checked": true,
35+
"controls": true,
36+
"default": true,
37+
"disabled": true,
38+
"formNoValidate": true,
39+
"hidden": true,
40+
"ismap": "",
41+
"itemScope": true,
42+
"loop": true,
43+
"multiple": true,
44+
"muted": true,
45+
"noValidate": true,
46+
"nomodule": "",
47+
"open": true,
48+
"playsInline": true,
49+
"readOnly": true,
50+
"required": true,
51+
"reversed": true,
52+
"selected": true,
53+
"truespeed": "",
54+
}
55+
`;
56+
57+
exports[`attributesToProps with HTML attribute converts non-standard attributes to React props 1`] = `
58+
Object {
59+
"itemID": 1337,
60+
"itemScope": true,
61+
}
62+
`;
63+
64+
exports[`attributesToProps with HTML attribute converts standard attributes to React props 1`] = `
65+
Object {
66+
"allowFullScreen": true,
67+
"charSet": "utf-8",
68+
"tabIndex": 1,
69+
}
70+
`;
71+
72+
exports[`attributesToProps with HTML attribute keeps \`data-*\` and \`aria-*\` attributes as is 1`] = `
73+
Object {
74+
"aria-live": "polite",
75+
"data-foo": "bar",
76+
}
77+
`;
78+
79+
exports[`attributesToProps with SVG attribute converts attributes to React props 1`] = `
80+
Object {
81+
"edgeMode": "edgeMode",
82+
"fillOpacity": "0.42",
83+
"fillRule": "evenodd",
84+
"glyphOrientationVertical": "auto",
85+
"horizAdvX": "9001",
86+
"stroke": "none",
87+
"xmlBase": "http://example.org",
88+
}
89+
`;
90+
91+
exports[`attributesToProps with SVG attribute keeps incorrectly capitalized attributes 1`] = `
92+
Object {
93+
"XLINK:HREF": "#",
94+
"YChannelSelector": "G",
95+
"ZoomAndPan": "disable",
96+
}
97+
`;
98+
99+
exports[`attributesToProps with custom attribute converts attributes named after Object properties 1`] = `
100+
Object {
101+
"__defineGetter__": "",
102+
"__defineSetter__": "",
103+
"__lookupGetter__": "",
104+
"__lookupSetter__": "",
105+
"constructor": "",
106+
"hasOwnProperty": "",
107+
"isPrototypeOf": "",
108+
"propertyIsEnumerable": "",
109+
"toLocaleString": "",
110+
"toString": "",
111+
"valueOf": "",
112+
}
113+
`;
114+
115+
exports[`attributesToProps with style attribute parses CSS style to JS object 1`] = `
4116
Object {
5117
"style": Object {
6118
"--custom-property": "#f00",

test/__snapshots__/dom-to-react.test.js.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`DOM to React converts <textarea> correctly 1`] = `
3+
exports[`domToReact converts <textarea> correctly 1`] = `
44
<textarea
55
defaultValue="foo"
66
/>
77
`;
88
9-
exports[`DOM to React converts SVG element with viewBox attribute 1`] = `
9+
exports[`domToReact converts SVG element with viewBox attribute 1`] = `
1010
<svg
1111
id="foo"
1212
viewBox="0 0 512 512"
@@ -15,7 +15,7 @@ exports[`DOM to React converts SVG element with viewBox attribute 1`] = `
1515
</svg>
1616
`;
1717
18-
exports[`DOM to React converts multiple DOM nodes to React 1`] = `
18+
exports[`domToReact converts multiple DOM nodes to React 1`] = `
1919
Array [
2020
<p>
2121
foo
@@ -26,13 +26,13 @@ Array [
2626
]
2727
`;
2828
29-
exports[`DOM to React converts single DOM node to React 1`] = `
29+
exports[`domToReact converts single DOM node to React 1`] = `
3030
<p>
3131
foo
3232
</p>
3333
`;
3434
35-
exports[`DOM to React does not escape <script> content 1`] = `
35+
exports[`domToReact does not escape <script> content 1`] = `
3636
<script
3737
dangerouslySetInnerHTML={
3838
Object {
@@ -42,7 +42,7 @@ exports[`DOM to React does not escape <script> content 1`] = `
4242
/>
4343
`;
4444
45-
exports[`DOM to React does not escape <style> content 1`] = `
45+
exports[`domToReact does not escape <style> content 1`] = `
4646
<style
4747
dangerouslySetInnerHTML={
4848
Object {
@@ -52,14 +52,14 @@ exports[`DOM to React does not escape <style> content 1`] = `
5252
/>
5353
`;
5454
55-
exports[`DOM to React does not modify attributes on custom elements 1`] = `
55+
exports[`domToReact does not modify attributes on custom elements 1`] = `
5656
<custom-button
5757
class="myClass"
5858
custom-attribute="value"
5959
/>
6060
`;
6161
62-
exports[`DOM to React skips doctype and comments 1`] = `
62+
exports[`domToReact skips doctype and comments 1`] = `
6363
Array [
6464
<p>
6565
foo
@@ -70,13 +70,13 @@ Array [
7070
]
7171
`;
7272
73-
exports[`DOM to React when React <16 removes unknown attributes 1`] = `
73+
exports[`domToReact when React <16 removes unknown attributes 1`] = `
7474
<custom-button
7575
className="myClass"
7676
/>
7777
`;
7878
79-
exports[`DOM to React when React >=16 preserves unknown attributes 1`] = `
79+
exports[`domToReact when React >=16 preserves unknown attributes 1`] = `
8080
<custom-button
8181
class="myClass"
8282
custom-attribute="value"

0 commit comments

Comments
 (0)