Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteban Beltran committed Feb 15, 2022
1 parent 66a0a0d commit 13caeb6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';

export const mockCasesContext: React.FC = (props) => {
return <>{props?.children ?? null}</>;
};
mockCasesContext.displayName = 'CasesContextMock';
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { createStore, State } from '../../../common/store';
import { mockHistory, Router } from '../../../common/mock/router';
import { mockTimelines } from '../../../common/mock/mock_timelines_plugin';
import { mockBrowserFields } from '../../../common/containers/source/mock';
import { mockCasesContext } from '../../../common/mock/mock_cases_context';

// Test will fail because we will to need to mock some core services to make the test work
// For now let's forget about SiemSearchBar and QueryBar
Expand Down Expand Up @@ -73,7 +74,7 @@ jest.mock('../../../common/lib/kibana', () => {
},
},
cases: {
getCasesContext: jest.fn(),
getCasesContext: mockCasesContext,
},
uiSettings: {
get: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useSourcererDataView } from '../../../../common/containers/sourcerer';
import { mockSourcererScope } from '../../../../common/containers/sourcerer/mocks';
import { Direction } from '../../../../../common/search_strategy';
import * as helpers from '../helpers';
import { mockCasesContext } from '../../../../common/mock/mock_cases_context';

jest.mock('../../../containers/index', () => ({
useTimelineEvents: jest.fn(),
Expand Down Expand Up @@ -59,6 +60,9 @@ jest.mock('../../../../common/lib/kibana', () => {
navigateToApp: jest.fn(),
getUrlForApp: jest.fn(),
},
cases: {
getCasesContext: () => mockCasesContext,
},
uiSettings: {
get: jest.fn(),
},
Expand Down

0 comments on commit 13caeb6

Please sign in to comment.