-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
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
23 changes: 23 additions & 0 deletions
23
src/tests/mutations/tournaments/copyTournamentRecord.test.ts
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import tournamentEngine from '@Engines/syncEngine'; | ||
import mocksEngine from '@Assemblies/engines/mock'; | ||
import { expect, test } from 'vitest'; | ||
|
||
// Constants | ||
import { INVALID_VALUES } from '@Constants/errorConditionConstants'; | ||
import { addDays } from '@Tools/dateTime'; | ||
|
||
test('can copy a tournamentRecord', () => { | ||
const startDate = '2024-05-01'; | ||
const tournamentId = 'tid'; | ||
mocksEngine.generateTournamentRecord({ startDate, tournamentId, drawProfiles: [{ drawSize: 8 }], setState: true }); | ||
let result = tournamentEngine.copyTournamentRecord(); | ||
expect(result.error).toEqual(INVALID_VALUES); | ||
result = tournamentEngine.copyTournamentRecord({ startDate: addDays(startDate, 7) }); | ||
expect(result.error).toEqual(INVALID_VALUES); | ||
result = tournamentEngine.copyTournamentRecord({ | ||
tournamentName: 'Tournament Copy', | ||
startDate: addDays(startDate, 7), | ||
}); | ||
expect(result.tournamentRecord.tournamentName).toEqual('Tournament Copy'); | ||
expect(result.tournamentRecord.tournamentId).not.toEqual(tournamentId); | ||
}); |
15 changes: 15 additions & 0 deletions
15
src/tests/mutations/tournaments/createTournamentRecord.test.ts
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import tournamentEngine from '@Engines/syncEngine'; | ||
import { expect, test } from 'vitest'; | ||
|
||
// Constants | ||
import { INVALID_DATE } from '@Constants/errorConditionConstants'; | ||
|
||
test('can create a tournamentRecord', () => { | ||
let result = tournamentEngine.createTournamentRecord(); | ||
expect(result.tournamentId).toBeDefined(); | ||
result = tournamentEngine.createTournamentRecord({ tournamentName: 'Tournament Name' }); | ||
expect(result.tournamentName).toEqual('Tournament Name'); | ||
expect(result.tournamentId).toBeDefined(); | ||
result = tournamentEngine.createTournamentRecord({ startDate: 'foo' }); | ||
expect(result.error).toEqual(INVALID_DATE); | ||
}); |