mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Added HOC filter test
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Store component filters should filter HOCs: 1: mount 1`] = `
|
||||
[root]
|
||||
▾ <Component>
|
||||
▾ <Component>
|
||||
<div>
|
||||
`;
|
||||
|
||||
exports[`Store component filters should filter HOCs: 2: hide all HOCs 1`] = `
|
||||
[root]
|
||||
▾ <Component>
|
||||
<div>
|
||||
`;
|
||||
|
||||
exports[`Store component filters should filter HOCs: 3: disable HOC filter 1`] = `
|
||||
[root]
|
||||
▾ <Component>
|
||||
▾ <Component>
|
||||
<div>
|
||||
`;
|
||||
|
||||
exports[`Store component filters should filter by display name: 1: mount 1`] = `
|
||||
[root]
|
||||
▾ <Foo>
|
||||
|
||||
@@ -167,4 +167,23 @@ describe('Store component filters', () => {
|
||||
|
||||
expect(store).toMatchSnapshot('3: hide components in a made up fake path');
|
||||
});
|
||||
|
||||
it('should filter HOCs', () => {
|
||||
const Component = () => <div>Hi</div>;
|
||||
const WrappedComponent = () => <Component />;
|
||||
WrappedComponent.displayName = 'withWrapper(Component)';
|
||||
|
||||
act(() =>
|
||||
ReactDOM.render(<WrappedComponent />, document.createElement('div'))
|
||||
);
|
||||
expect(store).toMatchSnapshot('1: mount');
|
||||
|
||||
act(() => (store.componentFilters = [utils.createHOCFilter(true)]));
|
||||
|
||||
expect(store).toMatchSnapshot('2: hide all HOCs');
|
||||
|
||||
act(() => (store.componentFilters = [utils.createHOCFilter(false)]));
|
||||
|
||||
expect(store).toMatchSnapshot('3: disable HOC filter');
|
||||
});
|
||||
});
|
||||
|
||||
+21
-12
@@ -60,18 +60,6 @@ export function beforeEachProfiling(): void {
|
||||
);
|
||||
}
|
||||
|
||||
export function createElementTypeFilter(
|
||||
elementType: ElementType,
|
||||
isEnabled: boolean = true
|
||||
) {
|
||||
const Types = require('src/types');
|
||||
return {
|
||||
type: Types.ComponentFilterElementType,
|
||||
isEnabled,
|
||||
value: elementType,
|
||||
};
|
||||
}
|
||||
|
||||
export function createDisplayNameFilter(
|
||||
source: string,
|
||||
isEnabled: boolean = true
|
||||
@@ -91,6 +79,27 @@ export function createDisplayNameFilter(
|
||||
};
|
||||
}
|
||||
|
||||
export function createHOCFilter(isEnabled: boolean = true) {
|
||||
const Types = require('src/types');
|
||||
return {
|
||||
type: Types.ComponentFilterHOC,
|
||||
isEnabled,
|
||||
isValid: true,
|
||||
};
|
||||
}
|
||||
|
||||
export function createElementTypeFilter(
|
||||
elementType: ElementType,
|
||||
isEnabled: boolean = true
|
||||
) {
|
||||
const Types = require('src/types');
|
||||
return {
|
||||
type: Types.ComponentFilterElementType,
|
||||
isEnabled,
|
||||
value: elementType,
|
||||
};
|
||||
}
|
||||
|
||||
export function createLocationFilter(
|
||||
source: string,
|
||||
isEnabled: boolean = true
|
||||
|
||||
Reference in New Issue
Block a user