Added HOC badges to Jest Store serialization

This commit is contained in:
Brian Vaughn
2019-06-07 14:10:49 -07:00
parent 21bb66a8c7
commit 88e59277e7
3 changed files with 19 additions and 12 deletions
@@ -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`] = `
+5 -5
View File
@@ -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)]));
+6 -1
View File
@@ -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) {