[Security Solution] expandable flyout small cleanup (#155515)

This commit is contained in:
Philippe Oberti 2023-04-21 15:59:20 -05:00 committed by GitHub
parent 8039fec178
commit 9b6c6bcd9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 73 deletions

View file

@ -54,7 +54,7 @@ describe('<HighlightedFields />', () => {
browserFields: {},
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<ExpandableFlyoutContext.Provider value={flyoutContextValue}>
<RightPanelContext.Provider value={panelContextValue}>
<HighlightedFields />
@ -62,11 +62,7 @@ describe('<HighlightedFields />', () => {
</ExpandableFlyoutContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
it('should render empty component if browserFields is null', () => {
@ -78,7 +74,7 @@ describe('<HighlightedFields />', () => {
browserFields: null,
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<ExpandableFlyoutContext.Provider value={flyoutContextValue}>
<RightPanelContext.Provider value={panelContextValue}>
<HighlightedFields />
@ -86,11 +82,7 @@ describe('<HighlightedFields />', () => {
</ExpandableFlyoutContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
it('should render empty component if eventId is null', () => {
@ -102,7 +94,7 @@ describe('<HighlightedFields />', () => {
browserFields: {},
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<ExpandableFlyoutContext.Provider value={flyoutContextValue}>
<RightPanelContext.Provider value={panelContextValue}>
<HighlightedFields />
@ -110,10 +102,6 @@ describe('<HighlightedFields />', () => {
</ExpandableFlyoutContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
});

View file

@ -33,7 +33,7 @@ export const HighlightedFields: FC = () => {
}, [eventId, indexName, openRightPanel, scopeId]);
if (!dataFormattedForFieldBrowser || !browserFields || !eventId) {
return <></>;
return null;
}
return (

View file

@ -33,16 +33,12 @@ describe('<MitreAttack />', () => {
},
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<RightPanelContext.Provider value={contextValue}>
<MitreAttack />
</RightPanelContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
});

View file

@ -37,17 +37,13 @@ describe('<Reason />', () => {
dataAsNestedObject: {},
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<RightPanelContext.Provider value={panelContextValue}>
<Reason />
</RightPanelContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
it('should render null if dataAsNestedObject is null', () => {
@ -55,17 +51,13 @@ describe('<Reason />', () => {
dataFormattedForFieldBrowser: [],
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<RightPanelContext.Provider value={panelContextValue}>
<Reason />
</RightPanelContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
it('should render null if renderer is null', () => {
const panelContextValue = {
@ -73,16 +65,12 @@ describe('<Reason />', () => {
dataFormattedForFieldBrowser: [],
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<RightPanelContext.Provider value={panelContextValue}>
<Reason />
</RightPanelContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
});

View file

@ -38,17 +38,13 @@ describe('<RiskScore />', () => {
getFieldsData: jest.fn(),
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<RightPanelContext.Provider value={contextValue}>
<RiskScore />
</RightPanelContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
it('should render empty component if getFieldsData is invalid', () => {
@ -56,16 +52,12 @@ describe('<RiskScore />', () => {
getFieldsData: jest.fn().mockImplementation(() => 123),
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<RightPanelContext.Provider value={contextValue}>
<RiskScore />
</RightPanelContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
});

View file

@ -38,17 +38,13 @@ describe('<DocumentSeverity />', () => {
getFieldsData: jest.fn(),
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<RightPanelContext.Provider value={contextValue}>
<DocumentSeverity />
</RightPanelContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
it('should render empty component if getFieldsData is invalid array', () => {
@ -56,17 +52,13 @@ describe('<DocumentSeverity />', () => {
getFieldsData: jest.fn().mockImplementation(() => ['abc']),
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<RightPanelContext.Provider value={contextValue}>
<DocumentSeverity />
</RightPanelContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
it('should render empty component if getFieldsData is invalid string', () => {
@ -74,16 +66,12 @@ describe('<DocumentSeverity />', () => {
getFieldsData: jest.fn().mockImplementation(() => 'abc'),
} as unknown as RightPanelContext;
const { baseElement } = render(
const { container } = render(
<RightPanelContext.Provider value={contextValue}>
<DocumentSeverity />
</RightPanelContext.Provider>
);
expect(baseElement).toMatchInlineSnapshot(`
<body>
<div />
</body>
`);
expect(container).toBeEmptyDOMElement();
});
});