mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Added HOC badges to Jest Store serialization
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
exports[`Store component filters should filter HOCs: 1: mount 1`] = `
|
||||
[root]
|
||||
▾ <Component>
|
||||
▾ <Component>
|
||||
<div>
|
||||
▾ <Component> [Bar][Foo]
|
||||
▾ <Component> [Foo]
|
||||
▾ <Component>
|
||||
<div>
|
||||
`;
|
||||
|
||||
exports[`Store component filters should filter HOCs: 2: hide all HOCs 1`] = `
|
||||
@@ -15,9 +16,10 @@ exports[`Store component filters should filter HOCs: 2: hide all HOCs 1`] = `
|
||||
|
||||
exports[`Store component filters should filter HOCs: 3: disable HOC filter 1`] = `
|
||||
[root]
|
||||
▾ <Component>
|
||||
▾ <Component>
|
||||
<div>
|
||||
▾ <Component> [Bar][Foo]
|
||||
▾ <Component> [Foo]
|
||||
▾ <Component>
|
||||
<div>
|
||||
`;
|
||||
|
||||
exports[`Store component filters should filter by display name: 1: mount 1`] = `
|
||||
|
||||
@@ -170,12 +170,12 @@ describe('Store component filters', () => {
|
||||
|
||||
it('should filter HOCs', () => {
|
||||
const Component = () => <div>Hi</div>;
|
||||
const WrappedComponent = () => <Component />;
|
||||
WrappedComponent.displayName = 'withWrapper(Component)';
|
||||
const Foo = () => <Component />;
|
||||
Foo.displayName = 'Foo(Component)';
|
||||
const Bar = () => <Foo />;
|
||||
Bar.displayName = 'Bar(Foo(Component))';
|
||||
|
||||
act(() =>
|
||||
ReactDOM.render(<WrappedComponent />, document.createElement('div'))
|
||||
);
|
||||
act(() => ReactDOM.render(<Bar />, document.createElement('div')));
|
||||
expect(store).toMatchSnapshot('1: mount');
|
||||
|
||||
act(() => (store.componentFilters = [utils.createHOCFilter(true)]));
|
||||
|
||||
@@ -22,13 +22,18 @@ export function printElement(element, includeWeight = false) {
|
||||
key = ` key="${element.key}"`;
|
||||
}
|
||||
|
||||
let hocs = '';
|
||||
if (element.hocDisplayNames !== null) {
|
||||
hocs = ` [${element.hocDisplayNames.join('][')}]`;
|
||||
}
|
||||
|
||||
let suffix = '';
|
||||
if (includeWeight) {
|
||||
suffix = ` (${element.isCollapsed ? 1 : element.weight})`;
|
||||
}
|
||||
|
||||
return `${' '.repeat(element.depth + 1)}${prefix} <${element.displayName ||
|
||||
'null'}${key}>${suffix}`;
|
||||
'null'}${key}>${hocs}${suffix}`;
|
||||
}
|
||||
|
||||
export function printOwnersList(elements, includeWeight = false) {
|
||||
|
||||
Reference in New Issue
Block a user