mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 05:13:32 +00:00
Allow time change from api (#1009)
Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
d8626ff324
commit
3895b37572
@@ -1,4 +1,4 @@
|
||||
import { coerceColour } from '../coerceType.js';
|
||||
import { coerceColour, coerceEnum } from '../coerceType.js';
|
||||
|
||||
describe('parses a colour string that is', () => {
|
||||
it('valid hex', () => {
|
||||
@@ -19,3 +19,21 @@ describe('parses a colour string that is', () => {
|
||||
expect(() => coerceColour(5)).toThrowError(Error('Invalid colour value received'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('match a string to an enum that is', () => {
|
||||
enum testEnum {
|
||||
'abc',
|
||||
'def',
|
||||
'ghi',
|
||||
}
|
||||
it('valid key', () => {
|
||||
const key = coerceEnum<testEnum>('abc', testEnum);
|
||||
expect(key).toBe('abc');
|
||||
});
|
||||
it('invalid key', () => {
|
||||
expect(() => coerceEnum('123', testEnum)).toThrowError(Error('Invalid value received'));
|
||||
});
|
||||
it('invalid type', () => {
|
||||
expect(() => coerceEnum(123, testEnum)).toThrowError(Error('Invalid value received'));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user