Files
ontime/apps/server/src/api-data/rundown/__mocks__/rundown.mocks.ts
T
Carlos Valente 1849b4d39f Deps migration (#1988)
* chore: migrate eslint to oxlint

* chore: migrate prettier to oxfmt

* chore: migrate typescript

* chore: toThrow should have a expected value

* chore: cast test value as Day

* chore: small title fix

* chore: mocks should be hoisted

* chore: incorrect async useage

* chore: test should be inside description

* chore: test sohuld include an expeced

* chore: oxfmt

---------

Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
2026-03-08 16:22:12 +01:00

86 lines
1.8 KiB
TypeScript

import {
CustomField,
OntimeDelay,
OntimeEvent,
OntimeGroup,
OntimeMilestone,
Rundown,
SupportedEntry,
} from 'ontime-types';
import { makeNewRundown } from '../../../models/dataModel.js';
const baseEvent = {
type: SupportedEntry.Event,
skip: false,
revision: 1,
};
const baseGroup = {
type: SupportedEntry.Group,
entries: [],
};
const baseMilestone = {
type: SupportedEntry.Milestone,
cue: '',
title: '',
};
/**
* Utility to create an Ontime event
*/
export function makeOntimeEvent(patch: Partial<OntimeEvent>): OntimeEvent {
return {
...baseEvent,
...patch,
} as OntimeEvent;
}
/**
* Utility to create a delay entry
*/
export function makeOntimeDelay(patch: Partial<OntimeDelay>): OntimeDelay {
return { id: 'delay', type: SupportedEntry.Delay, duration: 0, ...patch } as OntimeDelay;
}
/**
* Utility to create a group entry
*/
export function makeOntimeGroup(patch: Partial<OntimeGroup>): OntimeGroup {
return { id: 'group', ...baseGroup, ...patch } as OntimeGroup;
}
/**
* Utility to create a milestone entry
*/
export function makeOntimeMilestone(patch: Partial<OntimeMilestone>): OntimeMilestone {
return { id: 'milestone', ...baseMilestone, ...patch } as OntimeMilestone;
}
/**
* Utility to create a rundown object
*/
export function makeRundown(patch: Partial<Rundown>): Rundown {
return {
...makeNewRundown(),
...patch,
};
}
export function makeCustomField(patch: Partial<CustomField>): CustomField {
return {
type: 'text',
colour: '#000000',
label: 'Custom Field',
...patch,
};
}
/**
* Utility to generate a rundown of OntimeEvents form partial objects
*/
export function prepareTimedEvents(events: Partial<OntimeEvent>[]): OntimeEvent[] {
return events.map(makeOntimeEvent);
}