Skip to content

Commit

Permalink
test: ✅ update and extend test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
CourtHive committed Mar 27, 2024
1 parent 02ebaf1 commit 18e5b46
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
24 changes: 24 additions & 0 deletions src/tests/mutations/publishing/participantPublishing.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import mocksEngine from '@Assemblies/engines/mock';
import tournamentEngine from '@Engines/syncEngine';
import { expect, it } from 'vitest';

it('can publish and unpublish participants', () => {
mocksEngine.generateTournamentRecord({
participantsProfile: { participantsCount: 10 },
setState: true,
});

let result = tournamentEngine.publishParticipants();
expect(result.success).toEqual(true);

let publishState = tournamentEngine.getPublishState().publishState;
expect(publishState.tournament?.participants?.published).toEqual(true);
expect(publishState.tournament?.status?.published).toEqual(true);

result = tournamentEngine.unPublishParticipants();
expect(result.success).toEqual(true);

publishState = tournamentEngine.getPublishState().publishState;
expect(publishState.tournament?.status?.published).toEqual(false);
expect(publishState.tournament?.participants).toBeUndefined();
});
11 changes: 6 additions & 5 deletions src/tests/mutations/publishing/publishingEventData.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { constantToString } from '@Tools/strings';
import mocksEngine from '@Assemblies/engines/mock';
import tournamentEngine from '@Engines/syncEngine';
import mocksEngine from '@Assemblies/engines/mock';
import { constantToString } from '@Tools/strings';
import { expect, it } from 'vitest';

// constants and fixtures
Expand Down Expand Up @@ -787,9 +787,10 @@ it('can add or remove stages from a published draw', () => {
result = tournamentEngine.publishOrderOfPlay();
expect(result.success).toEqual(true);

result = tournamentEngine.competitionScheduleMatchUps({
usePublishState: true,
});
result = tournamentEngine.getPublishState();
expect(result.publishState.tournament.orderOfPlay.published).toEqual(true);

result = tournamentEngine.competitionScheduleMatchUps({ usePublishState: true });
expect(result.groupInfo).toBeDefined();

// expect only { stage: VOLUNTARY_CONSOLATION } matchUps to be present
Expand Down
24 changes: 5 additions & 19 deletions src/tests/mutations/scheduling/orderOfPlayPublishing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,26 +118,12 @@ it('can publish order of play for specified days', () => {

publishState = competitionEngine.getPublishState().publishState;
expect(publishState.tournament.orderOfPlay.published).toEqual(true);
expect(publishState.tournament.status.published).toEqual(true);

result = competitionEngine.unPublishOrderOfPlay({
removePriorValues: false,
});
result = competitionEngine.unPublishOrderOfPlay({ removePriorValues: false });
expect(result.success).toEqual(true);

result = competitionEngine.getState();
tournamentRecord = Object.values(result.tournamentRecords)[0] as Tournament;
expect(tournamentRecord.timeItems?.length).toEqual(3);
expect(tournamentRecord.timeItems?.[2].itemValue).toEqual({
[PUBLIC]: { status: { published: false, publishedEventIds: [] } },
});

result = competitionEngine.unPublishOrderOfPlay();
expect(result.success).toEqual(true);

result = competitionEngine.getState();
tournamentRecord = Object.values(result.tournamentRecords)[0] as Tournament;
expect(tournamentRecord.timeItems?.length).toEqual(2);
expect(tournamentRecord.timeItems?.[1].itemValue).toEqual({
[PUBLIC]: { status: { published: false, publishedEventIds: [] } },
});
publishState = competitionEngine.getPublishState().publishState;
expect(publishState.tournament.status.published).toEqual(false);
expect(publishState.tournament.orderOfPlay).toBeUndefined();
});

0 comments on commit 18e5b46

Please sign in to comment.