mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-03 06:28:01 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d9c2a9cfd |
@@ -1,23 +1,7 @@
|
|||||||
import { OntimeEvent, SupportedEvent } from 'ontime-types';
|
|
||||||
import { MILLIS_PER_HOUR, MILLIS_PER_MINUTE } from 'ontime-utils';
|
import { MILLIS_PER_HOUR, MILLIS_PER_MINUTE } from 'ontime-utils';
|
||||||
|
|
||||||
import { loadRoll } from '../rollUtils.js';
|
import { loadRoll } from '../rollUtils.js';
|
||||||
|
import { prepareTimedEvents, makeOntimeEvent } from '../rundown-service/__mocks__/rundown.mocks.js';
|
||||||
const baseEvent = {
|
|
||||||
type: SupportedEvent.Event,
|
|
||||||
skip: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
function makeOntimeEvent(patch: Partial<OntimeEvent>): OntimeEvent {
|
|
||||||
return {
|
|
||||||
...baseEvent,
|
|
||||||
...patch,
|
|
||||||
} as OntimeEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function prepareTimedEvents(events: Partial<OntimeEvent>[]): OntimeEvent[] {
|
|
||||||
return events.map(makeOntimeEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('loadRoll()', () => {
|
describe('loadRoll()', () => {
|
||||||
const eventlist = [
|
const eventlist = [
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { SupportedEvent, OntimeEvent, OntimeDelay } from 'ontime-types';
|
||||||
|
|
||||||
|
const baseEvent = {
|
||||||
|
type: SupportedEvent.Event,
|
||||||
|
skip: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility to create a Ontime event
|
||||||
|
*/
|
||||||
|
export function makeOntimeEvent(patch: Partial<OntimeEvent>): OntimeEvent {
|
||||||
|
return {
|
||||||
|
...baseEvent,
|
||||||
|
...patch,
|
||||||
|
} as OntimeEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility to create a delay event
|
||||||
|
*/
|
||||||
|
export function makeOntimeDelay(duration: number): OntimeDelay {
|
||||||
|
return { id: 'delay', type: SupportedEvent.Delay, duration };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility to generate a rundown of OntimeEvents form partial objects
|
||||||
|
*/
|
||||||
|
export function prepareTimedEvents(events: Partial<OntimeEvent>[]): OntimeEvent[] {
|
||||||
|
return events.map(makeOntimeEvent);
|
||||||
|
}
|
||||||
@@ -1,20 +1,8 @@
|
|||||||
import { OntimeBlock, OntimeDelay, OntimeEvent, OntimeRundown, SupportedEvent } from 'ontime-types';
|
import { OntimeBlock, OntimeEvent, OntimeRundown, SupportedEvent } from 'ontime-types';
|
||||||
import { apply } from '../delayUtils.js';
|
|
||||||
import { MILLIS_PER_HOUR } from 'ontime-utils';
|
import { MILLIS_PER_HOUR } from 'ontime-utils';
|
||||||
|
|
||||||
/**
|
import { apply } from '../delayUtils.js';
|
||||||
* Small utility to fill in the necessary data for the test
|
import { makeOntimeDelay, makeOntimeEvent } from '../__mocks__/rundown.mocks.js';
|
||||||
*/
|
|
||||||
function makeOntimeEvent(event: Partial<OntimeEvent>): OntimeEvent {
|
|
||||||
return { ...event, type: SupportedEvent.Event, revision: 1 } as OntimeEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Small utility to make a delay event
|
|
||||||
*/
|
|
||||||
function makeOntimeDelay(duration: number): OntimeDelay {
|
|
||||||
return { id: 'delay', type: SupportedEvent.Delay, duration } as OntimeDelay;
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('apply()', () => {
|
describe('apply()', () => {
|
||||||
it('applies a positive delay to the rundown', () => {
|
it('applies a positive delay to the rundown', () => {
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { TimerPhase, Playback } from 'ontime-types';
|
||||||
|
import { deepmerge } from 'ontime-utils';
|
||||||
|
import { RuntimeState } from '../runtimeState.js';
|
||||||
|
|
||||||
|
const baseState: RuntimeState = {
|
||||||
|
clock: 0,
|
||||||
|
currentBlock: {
|
||||||
|
block: null,
|
||||||
|
startedAt: null,
|
||||||
|
},
|
||||||
|
eventNow: null,
|
||||||
|
publicEventNow: null,
|
||||||
|
eventNext: null,
|
||||||
|
publicEventNext: null,
|
||||||
|
runtime: {
|
||||||
|
selectedEventIndex: null,
|
||||||
|
numEvents: 0,
|
||||||
|
offset: 0,
|
||||||
|
plannedStart: 0,
|
||||||
|
plannedEnd: 0,
|
||||||
|
actualStart: null,
|
||||||
|
expectedEnd: null,
|
||||||
|
},
|
||||||
|
timer: {
|
||||||
|
addedTime: 0,
|
||||||
|
current: null,
|
||||||
|
duration: null,
|
||||||
|
elapsed: null,
|
||||||
|
expectedFinish: null,
|
||||||
|
finishedAt: null,
|
||||||
|
phase: TimerPhase.None,
|
||||||
|
playback: Playback.Stop,
|
||||||
|
secondaryTimer: null,
|
||||||
|
startedAt: null,
|
||||||
|
},
|
||||||
|
_timer: {
|
||||||
|
forceFinish: null,
|
||||||
|
totalDelay: 0,
|
||||||
|
pausedAt: null,
|
||||||
|
secondaryTarget: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export function makeRuntimeStateData(patch?: Partial<RuntimeState>) {
|
||||||
|
return deepmerge(baseState, patch);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user