Skip to content

Commit 78761c3

Browse files
aickingaearon
authored andcommitted
Add unit tests for props to attribute mapping in SSR. (#9106)
* Added a handful of SSR unit tests, ported from a previous pull request. * Fixing linting errors * Fixed a test helper function to properly report errors. * Un-nested the new rendering tests. Updated the fiber test passing/not passing lists. * Edited to comply with the react/jsx-space-before-closing eslint rule, which will soon be merged into master. * Response to code review from @spicyj. Moved tests to separate file, reworked wording of test names, corrected use of canUseDom, and simplified tests against tagName. Thanks for the help, @spicyj! * Converted the unit tests to use async-await style. * Moved async-await babel transform for tests from .babelrc to preprocessor.js. * Response to code review in PR #9089. Thanks, @spicyj! * Fixing some bugs in the SSR unit tests. * Missed deleting some repeated code in the last commit. * Adding unit tests for property to attribute mapping in SSR. * Removing some redundant unit tests. * Oops. I forgot to re-run record-tests after c593dbc; fixing that here. * Reformatting for prettier so that the build will pass.
1 parent f606e0e commit 78761c3

4 files changed

Lines changed: 398 additions & 15 deletions

File tree

scripts/fiber/tests-failing.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,47 @@ src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
66
* gives source code refs for unknown prop warning for exact elements (ssr)
77
* gives source code refs for unknown prop warning for exact elements in composition (ssr)
88

9+
src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
10+
* renders a blank div with client render on top of good server markup
11+
* renders a div with inline styles with client render on top of good server markup
12+
* renders a self-closing tag with client render on top of good server markup
13+
* renders a self-closing tag as a child with client render on top of good server markup
14+
* renders simple numbers with client render on top of good server markup
15+
* renders simple strings with client render on top of good server markup
16+
* renders string prop with true value with client render on top of good server markup
17+
* renders string prop with false value with client render on top of good server markup
18+
* renders boolean prop with true value with client render on top of good server markup
19+
* renders boolean prop with false value with client render on top of good server markup
20+
* renders boolean prop with self value with client render on top of good server markup
21+
* renders boolean prop with "" value with client render on top of good server markup
22+
* renders boolean prop with string value with client render on top of good server markup
23+
* renders boolean prop with array value with client render on top of good server markup
24+
* renders boolean prop with object value with client render on top of good server markup
25+
* renders boolean prop with non-zero number value with client render on top of good server markup
26+
* renders boolean prop with zero value with client render on top of good server markup
27+
* renders download prop with true value with client render on top of good server markup
28+
* renders download prop with false value with client render on top of good server markup
29+
* renders download prop with string value with client render on top of good server markup
30+
* renders download prop with string "true" value with client render on top of good server markup
31+
* renders className prop with string value with client render on top of good server markup
32+
* renders className prop with empty string value with client render on top of good server markup
33+
* renders className prop with true value with client render on top of good server markup
34+
* renders className prop with false value with client render on top of good server markup
35+
* renders htmlFor with string value with client render on top of good server markup
36+
* renders htmlFor with an empty string with client render on top of good server markup
37+
* renders className prop with true value with client render on top of good server markup
38+
* renders className prop with false value with client render on top of good server markup
39+
* renders no ref attribute with client render on top of good server markup
40+
* renders no children attribute with client render on top of good server markup
41+
* renders no key attribute with client render on top of good server markup
42+
* renders no dangerouslySetInnerHTML attribute with client render on top of good server markup
43+
* renders no unknown attributes with client render on top of good server markup
44+
* renders unknown data- attributes with client render on top of good server markup
45+
* renders no unknown attributes for non-standard elements with client render on top of good server markup
46+
* renders unknown attributes for custom elements with client render on top of good server markup
47+
* renders unknown attributes for custom elements using is with client render on top of good server markup
48+
* renders no HTML events with client render on top of good server markup
49+
950
src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
1051
* can reconcile text merged by Node.normalize() alongside other elements
1152
* can reconcile text merged by Node.normalize()

scripts/fiber/tests-passing-except-dev.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,43 @@ src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
1010
* renders a div with inline styles with client render on top of bad server markup
1111
* renders a self-closing tag with client render on top of bad server markup
1212
* renders a self-closing tag as a child with client render on top of bad server markup
13+
* renders simple numbers with client render on top of bad server markup
14+
* renders simple strings with client render on top of bad server markup
15+
* renders string prop with true value with client render on top of bad server markup
16+
* renders string prop with false value with client render on top of bad server markup
17+
* renders boolean prop with true value with client render on top of bad server markup
18+
* renders boolean prop with false value with client render on top of bad server markup
19+
* renders boolean prop with self value with client render on top of bad server markup
20+
* renders boolean prop with "" value with client render on top of bad server markup
21+
* renders boolean prop with string value with client render on top of bad server markup
22+
* renders boolean prop with array value with client render on top of bad server markup
23+
* renders boolean prop with object value with client render on top of bad server markup
24+
* renders boolean prop with non-zero number value with client render on top of bad server markup
25+
* renders boolean prop with zero value with client render on top of bad server markup
26+
* renders download prop with true value with client render on top of bad server markup
27+
* renders download prop with false value with client render on top of bad server markup
28+
* renders download prop with string value with client render on top of bad server markup
29+
* renders download prop with string "true" value with client render on top of bad server markup
30+
* renders className prop with string value with client render on top of bad server markup
31+
* renders className prop with empty string value with client render on top of bad server markup
32+
* renders className prop with true value with client render on top of bad server markup
33+
* renders className prop with false value with client render on top of bad server markup
34+
* renders htmlFor with string value with client render on top of bad server markup
35+
* renders htmlFor with an empty string with client render on top of bad server markup
36+
* renders className prop with true value with client render on top of bad server markup
37+
* renders className prop with false value with client render on top of bad server markup
38+
* renders no ref attribute with client render on top of bad server markup
39+
* renders no children attribute with client render on top of bad server markup
40+
* renders no key attribute with client render on top of bad server markup
41+
* renders no dangerouslySetInnerHTML attribute with client render on top of bad server markup
42+
* renders no unknown attributes with server string render
43+
* renders no unknown attributes with client render on top of bad server markup
44+
* renders unknown data- attributes with client render on top of bad server markup
45+
* renders no unknown attributes for non-standard elements with server string render
46+
* renders no unknown attributes for non-standard elements with client render on top of bad server markup
47+
* renders unknown attributes for custom elements with client render on top of bad server markup
48+
* renders unknown attributes for custom elements using is with client render on top of bad server markup
49+
* renders no HTML events with client render on top of bad server markup
1350

1451
src/renderers/dom/shared/__tests__/ReactMount-test.js
1552
* should warn if mounting into dirty rendered markup

scripts/fiber/tests-passing.txt

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,16 +1064,80 @@ src/renderers/dom/shared/__tests__/ReactDOMSVG-test.js
10641064
src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js
10651065
* renders a blank div with server string render
10661066
* renders a blank div with clean client render
1067-
* renders a blank div with client render on top of good server markup
10681067
* renders a div with inline styles with server string render
10691068
* renders a div with inline styles with clean client render
1070-
* renders a div with inline styles with client render on top of good server markup
10711069
* renders a self-closing tag with server string render
10721070
* renders a self-closing tag with clean client render
1073-
* renders a self-closing tag with client render on top of good server markup
10741071
* renders a self-closing tag as a child with server string render
10751072
* renders a self-closing tag as a child with clean client render
1076-
* renders a self-closing tag as a child with client render on top of good server markup
1073+
* renders simple numbers with server string render
1074+
* renders simple numbers with clean client render
1075+
* renders simple strings with server string render
1076+
* renders simple strings with clean client render
1077+
* renders string prop with true value with server string render
1078+
* renders string prop with true value with clean client render
1079+
* renders string prop with false value with server string render
1080+
* renders string prop with false value with clean client render
1081+
* renders boolean prop with true value with server string render
1082+
* renders boolean prop with true value with clean client render
1083+
* renders boolean prop with false value with server string render
1084+
* renders boolean prop with false value with clean client render
1085+
* renders boolean prop with self value with server string render
1086+
* renders boolean prop with self value with clean client render
1087+
* renders boolean prop with "" value with server string render
1088+
* renders boolean prop with "" value with clean client render
1089+
* renders boolean prop with string value with server string render
1090+
* renders boolean prop with string value with clean client render
1091+
* renders boolean prop with array value with server string render
1092+
* renders boolean prop with array value with clean client render
1093+
* renders boolean prop with object value with server string render
1094+
* renders boolean prop with object value with clean client render
1095+
* renders boolean prop with non-zero number value with server string render
1096+
* renders boolean prop with non-zero number value with clean client render
1097+
* renders boolean prop with zero value with server string render
1098+
* renders boolean prop with zero value with clean client render
1099+
* renders download prop with true value with server string render
1100+
* renders download prop with true value with clean client render
1101+
* renders download prop with false value with server string render
1102+
* renders download prop with false value with clean client render
1103+
* renders download prop with string value with server string render
1104+
* renders download prop with string value with clean client render
1105+
* renders download prop with string "true" value with server string render
1106+
* renders download prop with string "true" value with clean client render
1107+
* renders className prop with string value with server string render
1108+
* renders className prop with string value with clean client render
1109+
* renders className prop with empty string value with server string render
1110+
* renders className prop with empty string value with clean client render
1111+
* renders className prop with true value with server string render
1112+
* renders className prop with true value with clean client render
1113+
* renders className prop with false value with server string render
1114+
* renders className prop with false value with clean client render
1115+
* renders htmlFor with string value with server string render
1116+
* renders htmlFor with string value with clean client render
1117+
* renders htmlFor with an empty string with server string render
1118+
* renders htmlFor with an empty string with clean client render
1119+
* renders className prop with true value with server string render
1120+
* renders className prop with true value with clean client render
1121+
* renders className prop with false value with server string render
1122+
* renders className prop with false value with clean client render
1123+
* renders no ref attribute with server string render
1124+
* renders no ref attribute with clean client render
1125+
* renders no children attribute with server string render
1126+
* renders no children attribute with clean client render
1127+
* renders no key attribute with server string render
1128+
* renders no key attribute with clean client render
1129+
* renders no dangerouslySetInnerHTML attribute with server string render
1130+
* renders no dangerouslySetInnerHTML attribute with clean client render
1131+
* renders no unknown attributes with clean client render
1132+
* renders unknown data- attributes with server string render
1133+
* renders unknown data- attributes with clean client render
1134+
* renders no unknown attributes for non-standard elements with clean client render
1135+
* renders unknown attributes for custom elements with server string render
1136+
* renders unknown attributes for custom elements with clean client render
1137+
* renders unknown attributes for custom elements using is with server string render
1138+
* renders unknown attributes for custom elements using is with clean client render
1139+
* renders no HTML events with server string render
1140+
* renders no HTML events with clean client render
10771141

10781142
src/renderers/dom/shared/__tests__/ReactDOMTextComponent-test.js
10791143
* updates a mounted text component in place

0 commit comments

Comments
 (0)