-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: created testing for admin league page
- Loading branch information
1 parent
d2f88e4
commit a894326
Showing
1 changed file
with
31 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,43 @@ | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import AdminLeagues from './page'; | ||
import { getUserLeagues } from '@/utils/utils'; | ||
import { getAllLeagueEntries } from '@/api/apiFunctions'; | ||
|
||
jest.mock('@/store/dataStore', () => ({ | ||
useDataStore: jest.fn().mockReturnValue({ | ||
user: { leagues: ['league1', 'league2'] }, | ||
}), | ||
useDataStore: jest.fn(() => ({ | ||
user: { | ||
documentId: '123', | ||
id: '1234', | ||
email: '[email protected]', | ||
leagues: ['league1', 'league2'], | ||
}, | ||
})), | ||
})); | ||
|
||
jest.mock('@/utils/utils', () => ({ | ||
getUserLeagues: jest.fn(() => Promise.resolve([])), | ||
cn: jest.fn(), | ||
})); | ||
|
||
jest.mock('@/api/apiFunctions', () => ({ | ||
getAllLeagueEntries: jest.fn(), | ||
})); | ||
|
||
describe('AdminLeagues', () => { | ||
render(<AdminLeagues />); | ||
|
||
const mockGetUserLeagues = getUserLeagues as jest.Mock; | ||
const mockGetAllLeagueEntries = getAllLeagueEntries as jest.Mock; | ||
|
||
beforeEach(() => { | ||
render(<AdminLeagues />); | ||
}) | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should render the League data table component', async () => { | ||
mockGetAllLeagueEntries.mockResolvedValue([]); | ||
|
||
mockGetUserLeagues.mockResolvedValue([]); | ||
|
||
await waitFor(() => { | ||
const leagueTable = screen.getByTestId('data-table'); | ||
expect(leagueTable).toBeInTheDocument(); | ||
|