Skip to content

Commit

Permalink
test: ✅ add test for hasParticipantsCount param of filterMatchUps
Browse files Browse the repository at this point in the history
  • Loading branch information
CourtHive committed Mar 22, 2024
1 parent 1fb32d6 commit 817bab9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/tests/queries/matchUps/matchUpFiltersHasParticipants.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import mocksEngine from '@Assemblies/engines/mock';
import tournamentEngine from '@Engines/syncEngine';
import { expect, test } from 'vitest';

test('hasParticipantsCount value filters matchUps', () => {
const startDate = '2023-06-16';
const venueId = 'vid';
const drawId = 'did';
const drawSize = 16;

mocksEngine.generateTournamentRecord({
venueProfiles: [{ venueId, courtsCount: 3 }],
drawProfiles: [{ drawId, drawSize: 16 }],
setState: true,
});

let matchUps = tournamentEngine.allCompetitionMatchUps({
nextMatchUps: true,
inContext: true,
}).matchUps;

const scheduleMatchUps = {
params: { scheduledDate: startDate, matchUps },
method: 'proAutoSchedule',
};

// First schedule all matchUps
let result = tournamentEngine.executionQueue([scheduleMatchUps]);
expect(result.success).toEqual(true);

result = tournamentEngine.competitionScheduleMatchUps();
expect(result.dateMatchUps.length).toEqual(drawSize - 1);

result = tournamentEngine.competitionScheduleMatchUps({ contextFilters: { hasParticipantsCount: 2 } });
expect(result.dateMatchUps.length).toEqual(drawSize / 2);
});
1 change: 1 addition & 0 deletions src/types/factoryTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ export type AddScheduleAttributeArgs = {
export type MatchUpFilters = {
matchUpStatuses?: MatchUpStatusUnion[];
excludeMatchUpStatuses?: string[];
hasParticipantsCount?: number;
isCollectionMatchUp?: boolean;
matchUpFormats?: string[];
roundPositions?: number[];
Expand Down

0 comments on commit 817bab9

Please sign in to comment.