diff --git a/packages/kbn-securitysolution-exception-list-components/src/exception_items/exception_items.test.tsx b/packages/kbn-securitysolution-exception-list-components/src/exception_items/exception_items.test.tsx index f1aa9931ca8a0..18db79fde497a 100644 --- a/packages/kbn-securitysolution-exception-list-components/src/exception_items/exception_items.test.tsx +++ b/packages/kbn-securitysolution-exception-list-components/src/exception_items/exception_items.test.tsx @@ -18,6 +18,7 @@ import { fireEvent, render } from '@testing-library/react'; import { ruleReferences } from '../mocks/rule_references.mock'; import { Pagination } from '@elastic/eui'; import { mockGetFormattedComments } from '../mocks/comments.mock'; +import { securityLinkAnchorComponent } from '../mocks/security_link_component.mock'; const onCreateExceptionListItem = jest.fn(); const onDeleteException = jest.fn(); @@ -133,17 +134,6 @@ describe('ExceptionsViewerItems', () => { describe('securityLinkAnchorComponent, formattedDateComponent, exceptionsUtilityComponent and getFormattedComments', () => { it('it should render sent securityLinkAnchorComponent', () => { - const securityLinkAnchorComponent = ({ - referenceName, - referenceId, - }: { - referenceName: string; - referenceId: string; - }) => ( -
- {referenceName} -
- ); const wrapper = render( ( -
- {referenceName} -
-); + describe('generateLinedRulesMenuItems', () => { it('should not render if the linkedRules length is falsy', () => { const result = generateLinedRulesMenuItems({ @@ -57,19 +51,7 @@ describe('generateLinedRulesMenuItems', () => { }); }); it('should render the second linked rule and apply the css when the length is > 1', () => { - const result: ReactElement[] = generateLinedRulesMenuItems({ - dataTestSubj, - linkedRules: [ - ...rules, - { - exception_lists: [], - id: '2a2b3c', - name: 'Simple Rule Query 2', - rule_id: 'rule-2', - }, - ], - securityLinkAnchorComponent, - }) as ReactElement[]; + const result: ReactElement[] = getSecurityLinkAction(dataTestSubj); const wrapper = render(result[1]); expect(wrapper).toMatchSnapshot(); diff --git a/packages/kbn-securitysolution-exception-list-components/src/header_menu/header_menu.test.tsx b/packages/kbn-securitysolution-exception-list-components/src/header_menu/header_menu.test.tsx index 0fdac05f48b5e..b07079c721ff7 100644 --- a/packages/kbn-securitysolution-exception-list-components/src/header_menu/header_menu.test.tsx +++ b/packages/kbn-securitysolution-exception-list-components/src/header_menu/header_menu.test.tsx @@ -9,6 +9,7 @@ import { fireEvent, render } from '@testing-library/react'; import React from 'react'; import { HeaderMenu } from '.'; import { actions } from '../mocks/header.mock'; +import { getSecurityLinkAction } from '../mocks/security_link_component.mock'; describe('HeaderMenu', () => { it('should render button icon with default settings', () => { @@ -91,7 +92,7 @@ describe('HeaderMenu', () => { }); it('should render custom Actions', () => { - const customActions = [

test

]; + const customActions = getSecurityLinkAction('headerMenuTest'); const wrapper = render( ); diff --git a/packages/kbn-securitysolution-exception-list-components/src/mocks/security_link_component.mock.tsx b/packages/kbn-securitysolution-exception-list-components/src/mocks/security_link_component.mock.tsx new file mode 100644 index 0000000000000..35b843a434452 --- /dev/null +++ b/packages/kbn-securitysolution-exception-list-components/src/mocks/security_link_component.mock.tsx @@ -0,0 +1,36 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import React, { ReactElement } from 'react'; +import { generateLinedRulesMenuItems } from '../generate_linked_rules_menu_item'; +import { rules } from './rule_references.mock'; +export const securityLinkAnchorComponent = ({ + referenceName, + referenceId, +}: { + referenceName: string; + referenceId: string; +}) => ( +
+ {referenceName} +
+); + +export const getSecurityLinkAction = (dataTestSubj: string) => + generateLinedRulesMenuItems({ + dataTestSubj, + linkedRules: [ + ...rules, + { + exception_lists: [], + id: '2a2b3c', + name: 'Simple Rule Query 2', + rule_id: 'rule-2', + }, + ], + securityLinkAnchorComponent, + }) as ReactElement[];