From 0e4cdc6f6417c0d5e1ee8d422ef92d08647c791f Mon Sep 17 00:00:00 2001 From: Siarhei Karol Date: Mon, 18 Nov 2024 17:32:53 +0500 Subject: [PATCH] additional test --- .../common/hooks/useSearchFiltersData.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/test/__tests__/common/hooks/useSearchFiltersData.test.ts b/src/test/__tests__/common/hooks/useSearchFiltersData.test.ts index 4c336f14..7fae0a0f 100644 --- a/src/test/__tests__/common/hooks/useSearchFiltersData.test.ts +++ b/src/test/__tests__/common/hooks/useSearchFiltersData.test.ts @@ -69,4 +69,17 @@ describe('useSearchFiltersData', () => { }); expect(setFacetsData).toHaveBeenCalledWith('facetsData'); }); + + test('onToggleFilterGroupState - updates selectedFacetsGroups', () => { + const setSelectedFacetsGroups = jest.fn(); + (useRecoilState as jest.Mock).mockReturnValue([['facet1'], setSelectedFacetsGroups]); + + const { result } = renderHook(() => useSearchFiltersData()); + + act(() => { + const updatedGroups = result.current.onToggleFilterGroupState('facet2', true); + expect(updatedGroups).toEqual(['facet1', 'facet2']); + expect(setSelectedFacetsGroups).toHaveBeenCalledWith(['facet1', 'facet2']); + }); + }); });