mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 02:13:48 +00:00
45fe669f0a
* refactor: simplify excel import * chore: add external deepmerge utility * chore: create import map utilities * chore: increase size limits on uploads * style: small presentation tweaks * feat: resolve times on excel import, refs #508
72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import { OntimeRundown, SupportedEvent } from 'ontime-types';
|
|
|
|
import { getNextEvent, getPreviousEvent } from './rundownUtils';
|
|
|
|
describe('getNextEvent()', () => {
|
|
it('returns the next event of type event', () => {
|
|
const testRundown = [
|
|
{ id: '1', type: SupportedEvent.Event },
|
|
{ id: '2', type: SupportedEvent.Event },
|
|
{ id: '3', type: SupportedEvent.Event },
|
|
];
|
|
|
|
const next = getNextEvent(testRundown as OntimeRundown, '1');
|
|
expect(next?.id).toBe('2');
|
|
});
|
|
it('ignores other event types', () => {
|
|
const testRundown = [
|
|
{ id: '1', type: SupportedEvent.Event },
|
|
{ id: '2', type: SupportedEvent.Delay },
|
|
{ id: '3', type: SupportedEvent.Block },
|
|
{ id: '4', type: SupportedEvent.Event },
|
|
];
|
|
|
|
const next = getNextEvent(testRundown as OntimeRundown, '1');
|
|
expect(next?.id).toBe('4');
|
|
});
|
|
it('returns null if none found', () => {
|
|
const testRundown = [
|
|
{ id: '1', type: SupportedEvent.Event },
|
|
{ id: '2', type: SupportedEvent.Delay },
|
|
{ id: '3', type: SupportedEvent.Block },
|
|
];
|
|
|
|
const next = getNextEvent(testRundown as OntimeRundown, '1');
|
|
expect(next).toBe(null);
|
|
});
|
|
});
|
|
|
|
describe('getPreviousEvent()', () => {
|
|
it('returns the previous event of type event', () => {
|
|
const testRundown = [
|
|
{ id: '1', type: SupportedEvent.Event },
|
|
{ id: '2', type: SupportedEvent.Event },
|
|
{ id: '3', type: SupportedEvent.Event },
|
|
];
|
|
|
|
const previous = getPreviousEvent(testRundown as OntimeRundown, '3');
|
|
expect(previous?.id).toBe('2');
|
|
});
|
|
it('ignores other event types', () => {
|
|
const testRundown = [
|
|
{ id: '1', type: SupportedEvent.Event },
|
|
{ id: '2', type: SupportedEvent.Delay },
|
|
{ id: '3', type: SupportedEvent.Block },
|
|
{ id: '4', type: SupportedEvent.Event },
|
|
];
|
|
|
|
const previous = getPreviousEvent(testRundown as OntimeRundown, '4');
|
|
expect(previous?.id).toBe('1');
|
|
});
|
|
it('returns null if none found', () => {
|
|
const testRundown = [
|
|
{ id: '2', type: SupportedEvent.Delay },
|
|
{ id: '3', type: SupportedEvent.Block },
|
|
{ id: '4', type: SupportedEvent.Event },
|
|
];
|
|
|
|
const previous = getNextEvent(testRundown as OntimeRundown, '1');
|
|
expect(previous).toBe(null);
|
|
});
|
|
});
|