-
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 #39 from ChetanKarwa/Bounty-List/fix-loaded-state
Bounty List: Fix loaded state when using filters of languages
- Loading branch information
Showing
5 changed files
with
55 additions
and
16 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
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
49 changes: 40 additions & 9 deletions
49
src/people/widgetViews/__tests__/WidgetSwitchViewer.spec.tsx
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 |
---|---|---|
@@ -1,14 +1,45 @@ | ||
import WidgetViewer from '../WidgetSwitchViewer'; | ||
import { uiStore } from '../../../store/ui'; | ||
// import crypto from 'crypto'; | ||
// import moment from 'moment'; | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import { useStores } from 'store'; | ||
import WidgetSwitchViewer from '../WidgetSwitchViewer'; | ||
|
||
beforeAll(() => {}); | ||
jest.mock('hooks', () => ({ | ||
useIsMobile: jest.fn() | ||
})); | ||
|
||
afterAll(() => {}); | ||
jest.mock('store', () => ({ | ||
useStores: jest.fn() | ||
})); | ||
|
||
describe('testing helpers', () => { | ||
test('test', () => { | ||
expect(true).toBe(true); | ||
describe('WidgetSwitchViewer Component', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
test('should display No results when there are no active list items with filter of languages', () => { | ||
// Mock return value for the store hook | ||
(useStores as jest.Mock).mockReturnValue({ | ||
main: { | ||
peopleBounties: [], | ||
peopleOffers: [], | ||
peoplePosts: [] | ||
} | ||
}); | ||
|
||
// Render the component with a selected widget and empty lists | ||
render( | ||
<WidgetSwitchViewer | ||
selectedWidget="wanted" | ||
currentItems={0} | ||
totalBounties={0} | ||
languageString="Typescript" | ||
/> | ||
); | ||
|
||
// Assert that <NoResults /> is present in the document | ||
expect(screen.getByText(/No results/i)).toBeInTheDocument(); | ||
}); | ||
|
||
// Additional tests for different conditions can be added here | ||
}); |