Skip to content

Commit

Permalink
Fix: created test for getAllLeagueEntries function
Browse files Browse the repository at this point in the history
  • Loading branch information
alexappleget committed Nov 18, 2024
1 parent b1afad7 commit 5998ed0
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion api/apiFunctions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
resetPassword,
resetRecoveredPassword,
updateUserEmail,
getTotalEntries
getTotalEntries,
getAllLeagueEntries
} from './apiFunctions';
import { IUser } from './apiFunctions.interface';
import { account, databases, ID } from './config';
Expand Down Expand Up @@ -564,4 +565,39 @@ describe('apiFunctions', () => {
]);
});
});

describe('getAllLeagueEntries()', () => {
it('should return all the entry data for a given league', async () => {
(databases.listDocuments as jest.Mock).mockResolvedValue({
documents: [
{
name: 'Entry 1',
user: '1234',
league: {
$id: 'league1',
survivors: ['123'],
participants: ['123', '1234'],
leagueName: 'League 1',
logo: '',
},
eliminated: true,
selectedTeams: ['Browns', 'Bears'],
},
],
});

const league = 'league1'

const result = await getAllLeagueEntries({ leagueId: league });

expect(result).toEqual([
{
entryName: 'Entry 1',
entryUser: '1234',
entrySelectedTeams: ['Browns', 'Bears'],
entryEliminated: true,
}
]);
});
});
});

0 comments on commit 5998ed0

Please sign in to comment.