[React@18] Fix remaining unit tests (#207195)

This commit is contained in:
Anton Dosov 2025-01-21 13:22:16 +01:00 committed by GitHub
parent 939c9fb71e
commit 5766467359
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 9 deletions

View file

@ -61,9 +61,10 @@ describe('When on the trusted applications page', () => {
it('should search using expected exception item fields', async () => {
const expectedFilterString = parseQueryFilterToKQL('fooFooFoo', SEARCHABLE_FIELDS);
const { findAllByTestId } = render();
const { getAllByTestId } = render();
await waitFor(async () => {
await expect(findAllByTestId('trustedAppsListPage-card')).resolves.toHaveLength(10);
expect(getAllByTestId('trustedAppsListPage-card')).toHaveLength(10);
});
apiMocks.responseProvider.exceptionsFind.mockClear();

View file

@ -20,9 +20,10 @@ jest.mock('../../../../sourcerer/containers');
jest.mock('../../open_timeline/use_timeline_status');
jest.mock('react-redux', () => {
const origin = jest.requireActual('react-redux');
const mockDispatch = jest.fn();
return {
...origin,
useDispatch: jest.fn(),
useDispatch: jest.fn(() => mockDispatch),
};
});
jest.mock('react-router-dom', () => {

View file

@ -88,12 +88,7 @@ export const useTimelineTypes = ({
const onFilterClicked = useCallback(
(tabId: TimelineType, tabStyle: TimelineTabsStyle) => {
setTimelineTypes((prevTimelineTypes) => {
if (prevTimelineTypes !== tabId) {
setTimelineTypes(tabId);
}
return prevTimelineTypes;
});
setTimelineTypes(tabId);
},
[setTimelineTypes]
);