Files
ontime/packages/utils/src/validate-events/validateEvent.test.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

35 lines
1.3 KiB
TypeScript

import { EndAction, TimerType } from 'ontime-types';
import { expect } from 'vitest';
import { validateEndAction, validateTimerType } from './validateEvent.js';
describe('validateEndAction()', () => {
it('recognizes a string representation of an action', () => {
const endAction = validateEndAction('load-next');
expect(endAction).toBe(EndAction.LoadNext);
});
it('returns fallback otherwise', () => {
const emptyAction = validateEndAction('', EndAction.LoadNext);
const invalidAction = validateEndAction('this-does-not-exist', EndAction.PlayNext);
expect(emptyAction).toBe(EndAction.LoadNext);
expect(invalidAction).toBe(EndAction.PlayNext);
});
});
describe('validateTimerType()', () => {
it('recognizes a string representation of an action', () => {
const timerType = validateTimerType('count-up');
expect(timerType).toBe(TimerType.CountUp);
});
it('returns fallback otherwise', () => {
const emptyType = validateTimerType('', TimerType.Clock);
const invalidType = validateTimerType('this-does-not-exist', TimerType.CountDown);
expect(emptyType).toBe(TimerType.Clock);
expect(invalidType).toBe(TimerType.CountDown);
});
it('handles a null value from params', () => {
const nullType = validateTimerType(null, TimerType.Clock);
expect(nullType).toBe(TimerType.Clock);
});
});