Over under (#771)

* feat: schedule offset
This commit is contained in:
Carlos Valente
2024-02-16 21:04:58 +01:00
committed by GitHub
parent 436a34aaee
commit 1a420a1ddd
34 changed files with 437 additions and 157 deletions
@@ -1,6 +1,6 @@
import { OntimeEvent, OntimeRundown, SupportedEvent } from 'ontime-types';
import { getNext, getNextEvent, getPrevious, getPreviousEvent, swapEventData } from './rundownUtils';
import { getLastEvent, getNext, getNextEvent, getPrevious, getPreviousEvent, swapEventData } from './rundownUtils';
describe('getNext()', () => {
it('returns the next event of type event', () => {
@@ -189,3 +189,23 @@ describe('swapEventData', () => {
});
});
});
describe('getLastEvent', () => {
it('returns the last event of type event', () => {
const testRundown = [
{ id: '1', type: SupportedEvent.Event },
{ id: '2', type: SupportedEvent.Delay },
{ id: '3', type: SupportedEvent.Event },
{ id: '4', type: SupportedEvent.Block },
];
const { lastEvent } = getLastEvent(testRundown as OntimeRundown);
expect(lastEvent?.id).toBe('3');
});
it('handles rundowns with a single event', () => {
const testRundown = [{ id: '1', type: SupportedEvent.Event }];
const { lastEvent } = getLastEvent(testRundown as OntimeRundown);
expect(lastEvent?.id).toBe('1');
});
});
@@ -74,7 +74,7 @@ export function getLastEvent(rundown: OntimeRundown): {
return { lastEvent: null, lastIndex: null };
}
for (let i = rundown.length - 1; i > 0; i--) {
for (let i = rundown.length - 1; i >= 0; i--) {
const lastEvent = rundown.at(i);
if (isOntimeEvent(lastEvent)) {
return { lastEvent, lastIndex: i };
@@ -100,7 +100,7 @@ export function getLastEventNormal(
return { lastEvent: null, lastIndex: null };
}
for (let i = order.length - 1; i > 0; i--) {
for (let i = order.length - 1; i >= 0; i--) {
const lastId = order[i];
const lastEvent = rundown[lastId];
if (isOntimeEvent(lastEvent)) {