mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 11:53:49 +00:00
None colour from API (#1063)
This commit is contained in:
committed by
GitHub
parent
b1838a5e9a
commit
9e63261b35
@@ -18,6 +18,13 @@ describe('parses a colour string that is', () => {
|
||||
it('not a string', () => {
|
||||
expect(() => coerceColour(5)).toThrowError(Error('Invalid colour value received'));
|
||||
});
|
||||
it('undefinde and null are not valid', () => {
|
||||
expect(() => coerceColour(null)).toThrowError(Error('Invalid colour value received'));
|
||||
expect(() => coerceColour(undefined)).toThrowError(Error('Invalid colour value received'));
|
||||
});
|
||||
it('empty string is allowed', () => {
|
||||
expect(coerceColour('')).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('match a string to an enum that is', () => {
|
||||
|
||||
@@ -90,7 +90,12 @@ export function coerceColour(value: unknown): string {
|
||||
if (!isColourHex(lowerCaseValue)) {
|
||||
throw new Error('Invalid hex colour received');
|
||||
}
|
||||
} else if (!(lowerCaseValue in cssColours)) {
|
||||
return lowerCaseValue;
|
||||
}
|
||||
if (lowerCaseValue === '') {
|
||||
return lowerCaseValue; // None colour the same as the UI 'Ø' button
|
||||
}
|
||||
if (!(lowerCaseValue in cssColours)) {
|
||||
throw new Error('Invalid colour name received');
|
||||
}
|
||||
return lowerCaseValue;
|
||||
|
||||
Reference in New Issue
Block a user