Skip to content

Commit

Permalink
fix(edges): unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtabBukhari committed Nov 13, 2024
1 parent c3f363a commit a67f649
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/components/App/SideBar/FilterSearch/__tests__/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit a67f649

Please sign in to comment.