Move all dev *Hook tests and ComponentTreeTestUtils to expectDev (#8350)
Tom Occhino committed
Nov 18, 2016 at 18:53 UTC
dfdff2b61aeac624bfda0ee1488de4b3179c992d
6 files changed
+127
-123
scripts/fiber/tests-failing.txt
-74
@@ -140,85 +140,11 @@ src/renderers/shared/__tests__/ReactPerf-test.js
140
* should work when measurement starts during reconciliation
141
142
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
143
-* uses displayName or Unknown for classic components
144
-* uses displayName, name, or ReactComponent for modern components
145
-* uses displayName, name, or Object for factory components
146
-* uses displayName, name, or StatelessComponent for functional components
147
-* reports a host tree correctly
148
-* reports a simple tree with composites correctly
149
-* reports a tree with composites correctly
150
-* ignores null children
151
-* ignores false children
152
-* reports text nodes as children
153
-* reports a single text node as a child
154
-* reports a single number node as a child
155
-* reports a zero as a child
156
-* skips empty nodes for multiple children
157
-* reports html content as no children
158
-* updates text of a single text child
159
-* updates from no children to a single text child
160
-* updates from a single text child to no children
161
-* updates from html content to a single text child
162
-* updates from a single text child to html content
163
-* updates from no children to multiple text children
164
-* updates from multiple text children to no children
165
-* updates from html content to multiple text children
166
-* updates from multiple text children to html content
167
-* updates from html content to no children
168
-* updates from no children to html content
169
-* updates from one text child to multiple text children
170
-* updates from multiple text children to one text child
171
-* updates text nodes when reordering
172
-* updates host nodes when reordering with keys
173
-* updates host nodes when reordering without keys
174
-* updates a single composite child of a different type
175
-* updates a single composite child of the same type
176
-* updates from no children to a single composite child
177
-* updates from a single composite child to no children
178
-* updates mixed children
179
-* updates with a host child
180
-* updates from null to a host child
181
-* updates from a host child to null
182
-* updates from a host child to a composite child
183
-* updates from a composite child to a host child
184
-* updates from null to a composite child
185
-* updates from a composite child to null
186
-* updates with a host child
187
-* updates from null to a host child
188
-* updates from a host child to null
189
-* updates from a host child to a composite child
190
-* updates from a composite child to a host child
191
-* updates from null to a composite child
192
-* updates from a composite child to null
193
-* tracks owner correctly
194
-* purges unmounted components automatically
195
-* reports update counts
196
-* does not report top-level wrapper as a root
197
-* registers inlined text nodes
143
* gets created
144
* can be retrieved by ID
200
-* works
145
146
src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
203
-* gets recorded for host roots
204
-* gets recorded for composite roots
205
-* gets recorded when a native is mounted deeply instead of null
206
-* gets recorded during mount
207
-* gets recorded during mount
208
-* gets recorded during mount
209
-* gets recorded during mount
210
-* gets recorded during an update from text content
211
-* gets recorded during an update from html
212
-* gets recorded during an update from children
147
* gets recorded during an update
214
-* gets recorded when composite renders to a different type
215
-* gets recorded when composite renders to null after a native
216
-* gets recorded during an update from text content
217
-* gets recorded during an update from html
218
-* gets recorded during an update from children
219
-* gets reported when a child is inserted
220
-* gets reported when a child is inserted
221
-* gets reported when a child is removed
148
149
src/renderers/shared/stack/reconciler/__tests__/ReactComponent-test.js
150
* should throw on invalid render targets
scripts/fiber/tests-passing-except-dev.txt
+78
@@ -65,6 +65,84 @@ src/renderers/dom/stack/client/__tests__/ReactMountDestruction-test.js
65
* should warn when unmounting a non-container root node
66
* should warn when unmounting a non-container, non-root node
67
68
+src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
69
+* uses displayName or Unknown for classic components
70
+* uses displayName, name, or ReactComponent for modern components
71
+* uses displayName, name, or Object for factory components
72
+* uses displayName, name, or StatelessComponent for functional components
73
+* reports a host tree correctly
74
+* reports a simple tree with composites correctly
75
+* reports a tree with composites correctly
76
+* ignores null children
77
+* ignores false children
78
+* reports text nodes as children
79
+* reports a single text node as a child
80
+* reports a single number node as a child
81
+* reports a zero as a child
82
+* skips empty nodes for multiple children
83
+* reports html content as no children
84
+* updates text of a single text child
85
+* updates from no children to a single text child
86
+* updates from a single text child to no children
87
+* updates from html content to a single text child
88
+* updates from a single text child to html content
89
+* updates from no children to multiple text children
90
+* updates from multiple text children to no children
91
+* updates from html content to multiple text children
92
+* updates from multiple text children to html content
93
+* updates from html content to no children
94
+* updates from no children to html content
95
+* updates from one text child to multiple text children
96
+* updates from multiple text children to one text child
97
+* updates text nodes when reordering
98
+* updates host nodes when reordering with keys
99
+* updates host nodes when reordering without keys
100
+* updates a single composite child of a different type
101
+* updates a single composite child of the same type
102
+* updates from no children to a single composite child
103
+* updates from a single composite child to no children
104
+* updates mixed children
105
+* updates with a host child
106
+* updates from null to a host child
107
+* updates from a host child to null
108
+* updates from a host child to a composite child
109
+* updates from a composite child to a host child
110
+* updates from null to a composite child
111
+* updates from a composite child to null
112
+* updates with a host child
113
+* updates from null to a host child
114
+* updates from a host child to null
115
+* updates from a host child to a composite child
116
+* updates from a composite child to a host child
117
+* updates from null to a composite child
118
+* updates from a composite child to null
119
+* tracks owner correctly
120
+* purges unmounted components automatically
121
+* reports update counts
122
+* does not report top-level wrapper as a root
123
+* registers inlined text nodes
124
+* works
125
+
126
+src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
127
+* gets recorded for host roots
128
+* gets recorded for composite roots
129
+* gets recorded when a native is mounted deeply instead of null
130
+* gets recorded during mount
131
+* gets recorded during mount
132
+* gets recorded during mount
133
+* gets recorded during mount
134
+* gets recorded during an update from text content
135
+* gets recorded during an update from html
136
+* gets recorded during an update from children
137
+* gets recorded when composite renders to a different type
138
+* gets recorded when composite renders to null after a native
139
+* gets recorded during an update from text content
140
+* gets recorded during an update from html
141
+* gets recorded during an update from children
142
+* gets reported when a child is inserted
143
+* gets reported when a child is inserted
144
+* gets reported when a child is removed
145
+
146
src/renderers/shared/stack/reconciler/__tests__/ReactChildReconciler-test.js
147
* warns for duplicated keys
148
* warns for duplicated keys with component stack info
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
+30
-30
@@ -54,11 +54,11 @@ describe('ReactComponentTreeHook', () => {
54
var rootDisplayNames = ReactComponentTreeTestUtils.getRootDisplayNames();
55
var registeredDisplayNames = ReactComponentTreeTestUtils.getRegisteredDisplayNames();
56
if (!expectedTree) {
57
- expect(rootDisplayNames).toEqual([]);
58
- expect(registeredDisplayNames).toEqual([]);
57
+ expectDev(rootDisplayNames).toEqual([]);
58
+ expectDev(registeredDisplayNames).toEqual([]);
59
} else if (andStayMounted) {
60
- expect(rootDisplayNames).toContain('Wrapper');
61
- expect(registeredDisplayNames).toContain('Wrapper');
60
+ expectDev(rootDisplayNames).toContain('Wrapper');
61
+ expectDev(registeredDisplayNames).toContain('Wrapper');
62
}
63
}
64
@@ -1692,48 +1692,48 @@ describe('ReactComponentTreeHook', () => {
1692
1693
ReactDOM.render(<div className="a" />, node);
1694
var divID = ReactComponentTreeHook.getRootIDs()[0];
1695
- expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1695
+ expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1696
1697
ReactDOM.render(<span className="a" />, node);
1698
var spanID = ReactComponentTreeHook.getRootIDs()[0];
1699
- expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1700
- expect(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(0);
1699
+ expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1700
+ expectDev(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(0);
1701
1702
ReactDOM.render(<span className="b" />, node);
1703
- expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1704
- expect(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(1);
1703
+ expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1704
+ expectDev(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(1);
1705
1706
ReactDOM.render(<span className="c" />, node);
1707
- expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1708
- expect(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(2);
1707
+ expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1708
+ expectDev(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(2);
1709
1710
ReactDOM.unmountComponentAtNode(node);
1711
- expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1712
- expect(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(0);
1711
+ expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
1712
+ expectDev(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(0);
1713
});
1714
1715
it('does not report top-level wrapper as a root', () => {
1716
var node = document.createElement('div');
1717
1718
ReactDOM.render(<div className="a" />, node);
1719
- expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['div']);
1719
+ expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['div']);
1720
1721
ReactDOM.render(<div className="b" />, node);
1722
- expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['div']);
1722
+ expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['div']);
1723
1724
ReactDOM.unmountComponentAtNode(node);
1725
- expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
1726
- expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
1725
+ expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
1726
+ expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
1727
});
1728
1729
it('registers inlined text nodes', () => {
1730
var node = document.createElement('div');
1731
1732
ReactDOM.render(<div>hi</div>, node);
1733
- expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual(['div', '#text']);
1733
+ expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual(['div', '#text']);
1734
1735
ReactDOM.unmountComponentAtNode(node);
1736
- expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
1736
+ expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
1737
});
1738
1739
describe('stack addenda', () => {
@@ -1746,19 +1746,19 @@ describe('ReactComponentTreeHook', () => {
1746
var Anon = React.createClass({displayName: null, render: () => null});
1747
var Orange = React.createClass({render: () => null});
1748
1749
- expect(getAddendum()).toBe(
1749
+ expectDev(getAddendum()).toBe(
1750
''
1751
);
1752
- expect(getAddendum(<div />)).toBe(
1752
+ expectDev(getAddendum(<div />)).toBe(
1753
'\n in div (at **)'
1754
);
1755
- expect(getAddendum(<Anon />)).toBe(
1755
+ expectDev(getAddendum(<Anon />)).toBe(
1756
'\n in Unknown (at **)'
1757
);
1758
- expect(getAddendum(<Orange />)).toBe(
1758
+ expectDev(getAddendum(<Orange />)).toBe(
1759
'\n in Orange (at **)'
1760
);
1761
- expect(getAddendum(React.createElement(Orange))).toBe(
1761
+ expectDev(getAddendum(React.createElement(Orange))).toBe(
1762
'\n in Orange'
1763
);
1764
@@ -1778,20 +1778,20 @@ describe('ReactComponentTreeHook', () => {
1778
this.forceUpdate();
1779
}
1780
render() {
1781
- expect(getAddendum()).toBe(
1781
+ expectDev(getAddendum()).toBe(
1782
'\n in S (at **)' +
1783
'\n in div (at **)' +
1784
'\n in R (created by Q)' +
1785
'\n in Q (at **)'
1786
);
1787
- expect(getAddendum(<span />)).toBe(
1787
+ expectDev(getAddendum(<span />)).toBe(
1788
'\n in span (at **)' +
1789
'\n in S (at **)' +
1790
'\n in div (at **)' +
1791
'\n in R (created by Q)' +
1792
'\n in Q (at **)'
1793
);
1794
- expect(getAddendum(React.createElement('span'))).toBe(
1794
+ expectDev(getAddendum(React.createElement('span'))).toBe(
1795
'\n in span (created by S)' +
1796
'\n in S (at **)' +
1797
'\n in div (at **)' +
@@ -1803,10 +1803,10 @@ describe('ReactComponentTreeHook', () => {
1803
}
1804
}
1805
ReactDOM.render(<Q />, document.createElement('div'));
1806
- expect(renders).toBe(2);
1806
+ expectDev(renders).toBe(2);
1807
1808
// Make sure owner is fetched for the top element too.
1809
- expect(getAddendum(rOwnedByQ)).toBe(
1809
+ expectDev(getAddendum(rOwnedByQ)).toBe(
1810
'\n in R (created by Q)'
1811
);
1812
});
@@ -1824,7 +1824,7 @@ describe('ReactComponentTreeHook', () => {
1824
}
1825
1826
var q = ReactDOM.render(<Q />, document.createElement('div'));
1827
- expect(getAddendum(ReactInstanceMap.get(q)._debugID)).toBe(
1827
+ expectDev(getAddendum(ReactInstanceMap.get(q)._debugID)).toBe(
1828
'\n in Q (at **)'
1829
);
1830
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.native.js
+17
-17
@@ -78,11 +78,11 @@ describe('ReactComponentTreeHook', () => {
78
var rootDisplayNames = ReactComponentTreeTestUtils.getRootDisplayNames();
79
var registeredDisplayNames = ReactComponentTreeTestUtils.getRegisteredDisplayNames();
80
if (!expectedTree) {
81
- expect(rootDisplayNames).toEqual([]);
82
- expect(registeredDisplayNames).toEqual([]);
81
+ expectDev(rootDisplayNames).toEqual([]);
82
+ expectDev(registeredDisplayNames).toEqual([]);
83
} else if (andStayMounted) {
84
- expect(rootDisplayNames).toContain('Wrapper');
85
- expect(registeredDisplayNames).toContain('Wrapper');
84
+ expectDev(rootDisplayNames).toContain('Wrapper');
85
+ expectDev(registeredDisplayNames).toContain('Wrapper');
86
}
87
}
88
@@ -1664,35 +1664,35 @@ describe('ReactComponentTreeHook', () => {
1664
it('reports update counts', () => {
1665
ReactNative.render(<View />, 1);
1666
var viewID = ReactComponentTreeHook.getRootIDs()[0];
1667
- expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1667
+ expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1668
1669
ReactNative.render(<Image />, 1);
1670
var imageID = ReactComponentTreeHook.getRootIDs()[0];
1671
- expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1672
- expect(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);
1671
+ expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1672
+ expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);
1673
1674
ReactNative.render(<Image />, 1);
1675
- expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1676
- expect(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(1);
1675
+ expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1676
+ expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(1);
1677
1678
ReactNative.render(<Image />, 1);
1679
- expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1680
- expect(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(2);
1679
+ expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1680
+ expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(2);
1681
1682
ReactNative.unmountComponentAtNode(1);
1683
- expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1684
- expect(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);
1683
+ expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
1684
+ expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);
1685
});
1686
1687
it('does not report top-level wrapper as a root', () => {
1688
ReactNative.render(<View><Image /></View>, 1);
1689
- expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['View']);
1689
+ expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['View']);
1690
1691
ReactNative.render(<View><Text /></View>, 1);
1692
- expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['View']);
1692
+ expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['View']);
1693
1694
ReactNative.unmountComponentAtNode(1);
1695
- expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
1696
- expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
1695
+ expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
1696
+ expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
1697
});
1698
});
src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
+1
-1
@@ -38,7 +38,7 @@ describe('ReactHostOperationHistoryHook', () => {
38
39
function assertHistoryMatches(expectedHistory) {
40
var actualHistory = ReactHostOperationHistoryHook.getHistory();
41
- expect(actualHistory).toEqual(expectedHistory);
41
+ expectDev(actualHistory).toEqual(expectedHistory);
42
}
43
44
describe('mount', () => {
src/test/ReactComponentTreeTestUtils.js
+1
-1
@@ -35,7 +35,7 @@ function expectTree(rootID, expectedTree, parentPath) {
35
function expectEqual(actual, expected, name) {
36
// Get Jasmine to print descriptive error messages.
37
// We pass path so that we know where the mismatch occurred.
38
- expect({
38
+ expectDev({
39
path,
40
[name]: actual,
41
}).toEqual({