From a67f649d4f1038f930526d7a96b830f21d39aac4 Mon Sep 17 00:00:00 2001 From: MahtabBukhari Date: Wed, 13 Nov 2024 12:33:49 +0500 Subject: [PATCH] fix(edges): unit tests --- .../SideBar/FilterSearch/__tests__/index.tsx | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/App/SideBar/FilterSearch/__tests__/index.tsx b/src/components/App/SideBar/FilterSearch/__tests__/index.tsx index fd39d5664..8f6a47a5e 100644 --- a/src/components/App/SideBar/FilterSearch/__tests__/index.tsx +++ b/src/components/App/SideBar/FilterSearch/__tests__/index.tsx @@ -33,29 +33,29 @@ const mockFetchData = jest.fn() const mockSetAbortRequests = jest.fn() const mockOnClose = jest.fn() -jest.mock('~/stores/useSchemaStore', () => ({ - useSchemaStore: jest.fn(), -})) - describe('FilterSearch Component', () => { const mockSetSchemas = jest.fn() + const mockSetSchemaLinks = jest.fn() const mockSchemaAll = [{ type: 'Type1' }, { type: 'Type2' }, { type: 'Type3' }] - const mockEdges = [{ edge_type: 'Edge1' }, { edge_type: 'Edge2' }, { edge_type: 'Edge3' }] beforeEach(() => { jest.clearAllMocks() + + // Mock useDataStore ;(useDataStore as jest.Mock).mockReturnValue({ setFilters: mockSetFilters, fetchData: mockFetchData, setAbortRequests: mockSetAbortRequests, }) - ;(useSchemaStore as jest.Mock).mockReturnValue({ - schemaAll: mockSchemaAll, - schemaLinks: mockEdges, - setSchemas: mockSetSchemas, - }) + + // Mock useSchemaStore to return an array for destructuring + ;(useSchemaStore as jest.Mock).mockReturnValue([mockSchemaAll, mockSetSchemas, mockEdges, mockSetSchemaLinks]) + + // Mock useFeatureFlagStore ;(useFeatureFlagStore as jest.Mock).mockReturnValue({ fastFiltersFeatureFlag: true }) + + // Mock getSchemaAll ;(getSchemaAll as jest.Mock).mockResolvedValue({ schemas: mockSchemaAll, edges: mockEdges, @@ -106,6 +106,7 @@ describe('FilterSearch Component', () => { await waitFor(() => { expect(mockSetFilters).toHaveBeenCalledWith({ node_type: ['Type1'], + edge_type: [], limit: 30, depth: '1', top_node_count: '10',