mirror of
https://github.com/facebook/react.git
synced 2026-02-26 18:58:05 +00:00
Move all dev *Hook tests and ComponentTreeTestUtils to expectDev (#8350)
This commit is contained in:
@@ -140,85 +140,11 @@ src/renderers/shared/__tests__/ReactPerf-test.js
|
||||
* should work when measurement starts during reconciliation
|
||||
|
||||
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
|
||||
* uses displayName or Unknown for classic components
|
||||
* uses displayName, name, or ReactComponent for modern components
|
||||
* uses displayName, name, or Object for factory components
|
||||
* uses displayName, name, or StatelessComponent for functional components
|
||||
* reports a host tree correctly
|
||||
* reports a simple tree with composites correctly
|
||||
* reports a tree with composites correctly
|
||||
* ignores null children
|
||||
* ignores false children
|
||||
* reports text nodes as children
|
||||
* reports a single text node as a child
|
||||
* reports a single number node as a child
|
||||
* reports a zero as a child
|
||||
* skips empty nodes for multiple children
|
||||
* reports html content as no children
|
||||
* updates text of a single text child
|
||||
* updates from no children to a single text child
|
||||
* updates from a single text child to no children
|
||||
* updates from html content to a single text child
|
||||
* updates from a single text child to html content
|
||||
* updates from no children to multiple text children
|
||||
* updates from multiple text children to no children
|
||||
* updates from html content to multiple text children
|
||||
* updates from multiple text children to html content
|
||||
* updates from html content to no children
|
||||
* updates from no children to html content
|
||||
* updates from one text child to multiple text children
|
||||
* updates from multiple text children to one text child
|
||||
* updates text nodes when reordering
|
||||
* updates host nodes when reordering with keys
|
||||
* updates host nodes when reordering without keys
|
||||
* updates a single composite child of a different type
|
||||
* updates a single composite child of the same type
|
||||
* updates from no children to a single composite child
|
||||
* updates from a single composite child to no children
|
||||
* updates mixed children
|
||||
* updates with a host child
|
||||
* updates from null to a host child
|
||||
* updates from a host child to null
|
||||
* updates from a host child to a composite child
|
||||
* updates from a composite child to a host child
|
||||
* updates from null to a composite child
|
||||
* updates from a composite child to null
|
||||
* updates with a host child
|
||||
* updates from null to a host child
|
||||
* updates from a host child to null
|
||||
* updates from a host child to a composite child
|
||||
* updates from a composite child to a host child
|
||||
* updates from null to a composite child
|
||||
* updates from a composite child to null
|
||||
* tracks owner correctly
|
||||
* purges unmounted components automatically
|
||||
* reports update counts
|
||||
* does not report top-level wrapper as a root
|
||||
* registers inlined text nodes
|
||||
* gets created
|
||||
* can be retrieved by ID
|
||||
* works
|
||||
|
||||
src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
|
||||
* gets recorded for host roots
|
||||
* gets recorded for composite roots
|
||||
* gets recorded when a native is mounted deeply instead of null
|
||||
* gets recorded during mount
|
||||
* gets recorded during mount
|
||||
* gets recorded during mount
|
||||
* gets recorded during mount
|
||||
* gets recorded during an update from text content
|
||||
* gets recorded during an update from html
|
||||
* gets recorded during an update from children
|
||||
* gets recorded during an update
|
||||
* gets recorded when composite renders to a different type
|
||||
* gets recorded when composite renders to null after a native
|
||||
* gets recorded during an update from text content
|
||||
* gets recorded during an update from html
|
||||
* gets recorded during an update from children
|
||||
* gets reported when a child is inserted
|
||||
* gets reported when a child is inserted
|
||||
* gets reported when a child is removed
|
||||
|
||||
src/renderers/shared/stack/reconciler/__tests__/ReactComponent-test.js
|
||||
* should throw on invalid render targets
|
||||
|
||||
@@ -65,6 +65,84 @@ src/renderers/dom/stack/client/__tests__/ReactMountDestruction-test.js
|
||||
* should warn when unmounting a non-container root node
|
||||
* should warn when unmounting a non-container, non-root node
|
||||
|
||||
src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js
|
||||
* uses displayName or Unknown for classic components
|
||||
* uses displayName, name, or ReactComponent for modern components
|
||||
* uses displayName, name, or Object for factory components
|
||||
* uses displayName, name, or StatelessComponent for functional components
|
||||
* reports a host tree correctly
|
||||
* reports a simple tree with composites correctly
|
||||
* reports a tree with composites correctly
|
||||
* ignores null children
|
||||
* ignores false children
|
||||
* reports text nodes as children
|
||||
* reports a single text node as a child
|
||||
* reports a single number node as a child
|
||||
* reports a zero as a child
|
||||
* skips empty nodes for multiple children
|
||||
* reports html content as no children
|
||||
* updates text of a single text child
|
||||
* updates from no children to a single text child
|
||||
* updates from a single text child to no children
|
||||
* updates from html content to a single text child
|
||||
* updates from a single text child to html content
|
||||
* updates from no children to multiple text children
|
||||
* updates from multiple text children to no children
|
||||
* updates from html content to multiple text children
|
||||
* updates from multiple text children to html content
|
||||
* updates from html content to no children
|
||||
* updates from no children to html content
|
||||
* updates from one text child to multiple text children
|
||||
* updates from multiple text children to one text child
|
||||
* updates text nodes when reordering
|
||||
* updates host nodes when reordering with keys
|
||||
* updates host nodes when reordering without keys
|
||||
* updates a single composite child of a different type
|
||||
* updates a single composite child of the same type
|
||||
* updates from no children to a single composite child
|
||||
* updates from a single composite child to no children
|
||||
* updates mixed children
|
||||
* updates with a host child
|
||||
* updates from null to a host child
|
||||
* updates from a host child to null
|
||||
* updates from a host child to a composite child
|
||||
* updates from a composite child to a host child
|
||||
* updates from null to a composite child
|
||||
* updates from a composite child to null
|
||||
* updates with a host child
|
||||
* updates from null to a host child
|
||||
* updates from a host child to null
|
||||
* updates from a host child to a composite child
|
||||
* updates from a composite child to a host child
|
||||
* updates from null to a composite child
|
||||
* updates from a composite child to null
|
||||
* tracks owner correctly
|
||||
* purges unmounted components automatically
|
||||
* reports update counts
|
||||
* does not report top-level wrapper as a root
|
||||
* registers inlined text nodes
|
||||
* works
|
||||
|
||||
src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
|
||||
* gets recorded for host roots
|
||||
* gets recorded for composite roots
|
||||
* gets recorded when a native is mounted deeply instead of null
|
||||
* gets recorded during mount
|
||||
* gets recorded during mount
|
||||
* gets recorded during mount
|
||||
* gets recorded during mount
|
||||
* gets recorded during an update from text content
|
||||
* gets recorded during an update from html
|
||||
* gets recorded during an update from children
|
||||
* gets recorded when composite renders to a different type
|
||||
* gets recorded when composite renders to null after a native
|
||||
* gets recorded during an update from text content
|
||||
* gets recorded during an update from html
|
||||
* gets recorded during an update from children
|
||||
* gets reported when a child is inserted
|
||||
* gets reported when a child is inserted
|
||||
* gets reported when a child is removed
|
||||
|
||||
src/renderers/shared/stack/reconciler/__tests__/ReactChildReconciler-test.js
|
||||
* warns for duplicated keys
|
||||
* warns for duplicated keys with component stack info
|
||||
|
||||
@@ -54,11 +54,11 @@ describe('ReactComponentTreeHook', () => {
|
||||
var rootDisplayNames = ReactComponentTreeTestUtils.getRootDisplayNames();
|
||||
var registeredDisplayNames = ReactComponentTreeTestUtils.getRegisteredDisplayNames();
|
||||
if (!expectedTree) {
|
||||
expect(rootDisplayNames).toEqual([]);
|
||||
expect(registeredDisplayNames).toEqual([]);
|
||||
expectDev(rootDisplayNames).toEqual([]);
|
||||
expectDev(registeredDisplayNames).toEqual([]);
|
||||
} else if (andStayMounted) {
|
||||
expect(rootDisplayNames).toContain('Wrapper');
|
||||
expect(registeredDisplayNames).toContain('Wrapper');
|
||||
expectDev(rootDisplayNames).toContain('Wrapper');
|
||||
expectDev(registeredDisplayNames).toContain('Wrapper');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1692,48 +1692,48 @@ describe('ReactComponentTreeHook', () => {
|
||||
|
||||
ReactDOM.render(<div className="a" />, node);
|
||||
var divID = ReactComponentTreeHook.getRootIDs()[0];
|
||||
expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
|
||||
ReactDOM.render(<span className="a" />, node);
|
||||
var spanID = ReactComponentTreeHook.getRootIDs()[0];
|
||||
expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(0);
|
||||
|
||||
ReactDOM.render(<span className="b" />, node);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(1);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(1);
|
||||
|
||||
ReactDOM.render(<span className="c" />, node);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(2);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(2);
|
||||
|
||||
ReactDOM.unmountComponentAtNode(node);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(divID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(spanID)).toEqual(0);
|
||||
});
|
||||
|
||||
it('does not report top-level wrapper as a root', () => {
|
||||
var node = document.createElement('div');
|
||||
|
||||
ReactDOM.render(<div className="a" />, node);
|
||||
expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['div']);
|
||||
expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['div']);
|
||||
|
||||
ReactDOM.render(<div className="b" />, node);
|
||||
expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['div']);
|
||||
expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['div']);
|
||||
|
||||
ReactDOM.unmountComponentAtNode(node);
|
||||
expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
|
||||
expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
|
||||
expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
|
||||
expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
|
||||
});
|
||||
|
||||
it('registers inlined text nodes', () => {
|
||||
var node = document.createElement('div');
|
||||
|
||||
ReactDOM.render(<div>hi</div>, node);
|
||||
expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual(['div', '#text']);
|
||||
expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual(['div', '#text']);
|
||||
|
||||
ReactDOM.unmountComponentAtNode(node);
|
||||
expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
|
||||
expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
|
||||
});
|
||||
|
||||
describe('stack addenda', () => {
|
||||
@@ -1746,19 +1746,19 @@ describe('ReactComponentTreeHook', () => {
|
||||
var Anon = React.createClass({displayName: null, render: () => null});
|
||||
var Orange = React.createClass({render: () => null});
|
||||
|
||||
expect(getAddendum()).toBe(
|
||||
expectDev(getAddendum()).toBe(
|
||||
''
|
||||
);
|
||||
expect(getAddendum(<div />)).toBe(
|
||||
expectDev(getAddendum(<div />)).toBe(
|
||||
'\n in div (at **)'
|
||||
);
|
||||
expect(getAddendum(<Anon />)).toBe(
|
||||
expectDev(getAddendum(<Anon />)).toBe(
|
||||
'\n in Unknown (at **)'
|
||||
);
|
||||
expect(getAddendum(<Orange />)).toBe(
|
||||
expectDev(getAddendum(<Orange />)).toBe(
|
||||
'\n in Orange (at **)'
|
||||
);
|
||||
expect(getAddendum(React.createElement(Orange))).toBe(
|
||||
expectDev(getAddendum(React.createElement(Orange))).toBe(
|
||||
'\n in Orange'
|
||||
);
|
||||
|
||||
@@ -1778,20 +1778,20 @@ describe('ReactComponentTreeHook', () => {
|
||||
this.forceUpdate();
|
||||
}
|
||||
render() {
|
||||
expect(getAddendum()).toBe(
|
||||
expectDev(getAddendum()).toBe(
|
||||
'\n in S (at **)' +
|
||||
'\n in div (at **)' +
|
||||
'\n in R (created by Q)' +
|
||||
'\n in Q (at **)'
|
||||
);
|
||||
expect(getAddendum(<span />)).toBe(
|
||||
expectDev(getAddendum(<span />)).toBe(
|
||||
'\n in span (at **)' +
|
||||
'\n in S (at **)' +
|
||||
'\n in div (at **)' +
|
||||
'\n in R (created by Q)' +
|
||||
'\n in Q (at **)'
|
||||
);
|
||||
expect(getAddendum(React.createElement('span'))).toBe(
|
||||
expectDev(getAddendum(React.createElement('span'))).toBe(
|
||||
'\n in span (created by S)' +
|
||||
'\n in S (at **)' +
|
||||
'\n in div (at **)' +
|
||||
@@ -1803,10 +1803,10 @@ describe('ReactComponentTreeHook', () => {
|
||||
}
|
||||
}
|
||||
ReactDOM.render(<Q />, document.createElement('div'));
|
||||
expect(renders).toBe(2);
|
||||
expectDev(renders).toBe(2);
|
||||
|
||||
// Make sure owner is fetched for the top element too.
|
||||
expect(getAddendum(rOwnedByQ)).toBe(
|
||||
expectDev(getAddendum(rOwnedByQ)).toBe(
|
||||
'\n in R (created by Q)'
|
||||
);
|
||||
});
|
||||
@@ -1824,7 +1824,7 @@ describe('ReactComponentTreeHook', () => {
|
||||
}
|
||||
|
||||
var q = ReactDOM.render(<Q />, document.createElement('div'));
|
||||
expect(getAddendum(ReactInstanceMap.get(q)._debugID)).toBe(
|
||||
expectDev(getAddendum(ReactInstanceMap.get(q)._debugID)).toBe(
|
||||
'\n in Q (at **)'
|
||||
);
|
||||
|
||||
|
||||
@@ -78,11 +78,11 @@ describe('ReactComponentTreeHook', () => {
|
||||
var rootDisplayNames = ReactComponentTreeTestUtils.getRootDisplayNames();
|
||||
var registeredDisplayNames = ReactComponentTreeTestUtils.getRegisteredDisplayNames();
|
||||
if (!expectedTree) {
|
||||
expect(rootDisplayNames).toEqual([]);
|
||||
expect(registeredDisplayNames).toEqual([]);
|
||||
expectDev(rootDisplayNames).toEqual([]);
|
||||
expectDev(registeredDisplayNames).toEqual([]);
|
||||
} else if (andStayMounted) {
|
||||
expect(rootDisplayNames).toContain('Wrapper');
|
||||
expect(registeredDisplayNames).toContain('Wrapper');
|
||||
expectDev(rootDisplayNames).toContain('Wrapper');
|
||||
expectDev(registeredDisplayNames).toContain('Wrapper');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1664,35 +1664,35 @@ describe('ReactComponentTreeHook', () => {
|
||||
it('reports update counts', () => {
|
||||
ReactNative.render(<View />, 1);
|
||||
var viewID = ReactComponentTreeHook.getRootIDs()[0];
|
||||
expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
|
||||
ReactNative.render(<Image />, 1);
|
||||
var imageID = ReactComponentTreeHook.getRootIDs()[0];
|
||||
expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);
|
||||
|
||||
ReactNative.render(<Image />, 1);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(1);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(1);
|
||||
|
||||
ReactNative.render(<Image />, 1);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(2);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(2);
|
||||
|
||||
ReactNative.unmountComponentAtNode(1);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
expect(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(viewID)).toEqual(0);
|
||||
expectDev(ReactComponentTreeHook.getUpdateCount(imageID)).toEqual(0);
|
||||
});
|
||||
|
||||
it('does not report top-level wrapper as a root', () => {
|
||||
ReactNative.render(<View><Image /></View>, 1);
|
||||
expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['View']);
|
||||
expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['View']);
|
||||
|
||||
ReactNative.render(<View><Text /></View>, 1);
|
||||
expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['View']);
|
||||
expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual(['View']);
|
||||
|
||||
ReactNative.unmountComponentAtNode(1);
|
||||
expect(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
|
||||
expect(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
|
||||
expectDev(ReactComponentTreeTestUtils.getRootDisplayNames()).toEqual([]);
|
||||
expectDev(ReactComponentTreeTestUtils.getRegisteredDisplayNames()).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('ReactHostOperationHistoryHook', () => {
|
||||
|
||||
function assertHistoryMatches(expectedHistory) {
|
||||
var actualHistory = ReactHostOperationHistoryHook.getHistory();
|
||||
expect(actualHistory).toEqual(expectedHistory);
|
||||
expectDev(actualHistory).toEqual(expectedHistory);
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
|
||||
@@ -35,7 +35,7 @@ function expectTree(rootID, expectedTree, parentPath) {
|
||||
function expectEqual(actual, expected, name) {
|
||||
// Get Jasmine to print descriptive error messages.
|
||||
// We pass path so that we know where the mismatch occurred.
|
||||
expect({
|
||||
expectDev({
|
||||
path,
|
||||
[name]: actual,
|
||||
}).toEqual({
|
||||
|
||||
Reference in New Issue
Block a user