Allow time change from api (#1009)

Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
This commit is contained in:
Alex Christoffer Rasmussen
2024-06-02 15:21:09 +02:00
committed by GitHub
parent d8626ff324
commit 3895b37572
6 changed files with 88 additions and 14 deletions
@@ -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'));
});
});