-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from ChetanKarwa/TribesPage/fix-tags-dropdown
Tribes page - Fix tags dropdown in tribes page
- Loading branch information
Showing
2 changed files
with
107 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { useStores } from 'store'; | ||
import { useFuse } from 'hooks'; | ||
import Body from '../Body'; | ||
|
||
jest.mock('hooks', () => ({ | ||
...jest.requireActual('hooks'), | ||
useIsMobile: jest.fn(), | ||
useScreenWidth: jest.fn(), | ||
useFuse: jest.fn() | ||
})); | ||
|
||
jest.mock('store', () => ({ | ||
useStores: jest.fn() | ||
})); | ||
|
||
describe('Tribes Body Component', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('should display No results when there are no tribes on search', async () => { | ||
// Mock return value for the store hook | ||
(useStores as jest.Mock).mockReturnValue({ | ||
main: { | ||
tribes: [], | ||
getTribes: jest.fn() | ||
}, | ||
ui: { | ||
peoplePageNumber: 1, | ||
searchText: 'abc', | ||
tags: [] | ||
} | ||
}); | ||
|
||
(useFuse as jest.Mock).mockReturnValue([]); | ||
|
||
// Render the component with a selected widget and empty lists | ||
render(<Body />); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText(/No results/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |