-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Endpoint][Host Isolation] Send case ids from UI t…
…o isolate api (#99484)
- Loading branch information
Showing
12 changed files
with
235 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ution/public/detections/containers/detection_engine/alerts/use_cases_from_alerts.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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 { renderHook } from '@testing-library/react-hooks'; | ||
import { useCasesFromAlerts } from './use_cases_from_alerts'; | ||
import * as api from './api'; | ||
import { useAppToasts } from '../../../../common/hooks/use_app_toasts'; | ||
import { useAppToastsMock } from '../../../../common/hooks/use_app_toasts.mock'; | ||
import { mockCaseIdsFromAlertId } from './mock'; | ||
|
||
jest.mock('./api'); | ||
jest.mock('../../../../common/hooks/use_app_toasts'); | ||
|
||
describe('useCasesFromAlerts hook', () => { | ||
let appToastsMock: jest.Mocked<ReturnType<typeof useAppToastsMock.create>>; | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
appToastsMock = useAppToastsMock.create(); | ||
(useAppToasts as jest.Mock).mockReturnValue(appToastsMock); | ||
}); | ||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('returns an array of caseIds', async () => { | ||
const spyOnCases = jest.spyOn(api, 'getCaseIdsFromAlertId'); | ||
const { result, waitForNextUpdate } = renderHook(() => | ||
useCasesFromAlerts({ alertId: 'anAlertId' }) | ||
); | ||
await waitForNextUpdate(); | ||
expect(spyOnCases).toHaveBeenCalledTimes(1); | ||
expect(result.current).toEqual({ | ||
loading: false, | ||
caseIds: mockCaseIdsFromAlertId, | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.