From 0b0598ac5b13e25db20fe5f660fb5bfccf48367b Mon Sep 17 00:00:00 2001 From: Patryk Kopycinski Date: Tue, 21 Jul 2020 13:27:10 +0200 Subject: [PATCH] fix tests --- .../timelines/pages/timelines_page.test.tsx | 16 +++++++++++++--- .../public/timelines/pages/timelines_page.tsx | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.test.tsx b/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.test.tsx index 33796f53b2458..f9097ddef6490 100644 --- a/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.test.tsx @@ -8,7 +8,7 @@ import { shallow, ShallowWrapper } from 'enzyme'; import React from 'react'; import { useKibana } from '../../common/lib/kibana'; -import { TimelinesPage } from './timelines_page'; +import { TimelinesPageComponent } from './timelines_page'; jest.mock('react-router-dom', () => { const originalModule = jest.requireActual('react-router-dom'); @@ -21,6 +21,16 @@ jest.mock('react-router-dom', () => { }; }); jest.mock('../../overview/components/events_by_dataset'); +jest.mock('../../common/containers/source', () => { + const originalModule = jest.requireActual('../../common/containers/source'); + + return { + ...originalModule, + useWithSource: jest.fn().mockReturnValue({ + indicesExist: true, + }), + }; +}); jest.mock('../../common/lib/kibana', () => { const originalModule = jest.requireActual('../../common/lib/kibana'); @@ -46,7 +56,7 @@ describe('TimelinesPageComponent', () => { }, }, }); - wrapper = shallow(); + wrapper = shallow(); }); afterAll(() => { @@ -92,7 +102,7 @@ describe('TimelinesPageComponent', () => { }, }, }); - wrapper = shallow(); + wrapper = shallow(); }); afterAll(() => { diff --git a/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.tsx b/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.tsx index 0abad68f1eaaa..b59f9e90f8e74 100644 --- a/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.tsx +++ b/x-pack/plugins/security_solution/public/timelines/pages/timelines_page.tsx @@ -32,7 +32,7 @@ const TimelinesContainer = styled.div` export const DEFAULT_SEARCH_RESULTS_PER_PAGE = 10; -const TimelinesPageComponent: React.FC = () => { +export const TimelinesPageComponent: React.FC = () => { const { tabName } = useParams(); const [importDataModalToggle, setImportDataModalToggle] = useState(false); const onImportTimelineBtnClick = useCallback(() => {