Skip to main content

mocksEngine

import { mocksEngine } from 'tods-competition-factory';

mocksEngine generates complete tournament objects, or tournamentRecords, as well as mock persons, participants and matchUp outcomes.

Simple Example

Generates a tournament record with, by default, 32 participants.

const { tournamentRecord } = mocksEngine.generateTournamentRecord();

drawProfiles

In testing, very specific scenarios are required. Any number of draws can be added to a generated tournament, and scores for specific matchUps within the generated draw structures can be added as well.

The completed matchUps in this example may be found by navigating in the Result panel below:

tournamentRecord => events[0] => drawDefinitions[0] => structures[0]

See Concepts => Context for more direct access to matchUps.

Live Editor
Result
Loading...
note

drawProfiles may contain any of the parameters normally passed to generateDrawDefinition, with the addition of { withPlayoffs } which may contain any of the parameters passed to addPlayoffStructures.

Additionally, the parameter idPrefix may be used to define a string value to prepend generated matchUpIds, which will then include roundNumber and roundPosition.

score completion

In the following example a Doubles draw with 32 positions is generated with 30 PAIR participants, leaving two positions to be filled with BYEs. The score for the second matchUp in the first round is completed.

Live Editor
Result
Loading...

eventProfiles

eventProfiles enable multiple draws to be generated in a single event.

const eventProfiles = [
{
eventName: 'Event Flights Test',
eventType: SINGLES,
category: {
categoryName: 'U12',
},
matchUpFormat: FORMAT_STANDARD,
drawProfiles: [
{
drawSize: 16,
drawName: 'Qualifying Draw',
stage: QUALIFYING,
},
{
drawSize: 32,
qualifyingPositions: 4,
drawName: 'Main Draw',
drawType: COMPASS,
},
{
drawName: 'Consolation Draw',
stage: VOLUNTARY_CONSOLATION,
},
],
},
];
const {
eventIds: [eventId],
drawIds,
} = mocksEngine.generateTournamentRecord({
eventProfiles,
});