Skip to content

Commit 65580d3

Browse files
test(attributes-to-props): add cases and refactor to snapshots
1 parent 08370e4 commit 65580d3

File tree

2 files changed

+305
-232
lines changed

2 files changed

+305
-232
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",

0 commit comments

Comments
 (0)