Files
ontime/packages/utils/src/regex-utils/isColourHex.test.ts
T
Alex Christoffer Rasmussen 1343818917 Improve change api (#628)
* fix: jsdoc comments

* more human casting of string values to boolean

* add coerceColour to get named colors to work

* cue can't pass isKeyOfType event check

* dont mutate value

* alloow cue in eventDef

* lint

* css named or hex formatting

* "sideEffects": false

* test colour hex regex

* roll eventDef back to master

* parse property

* don't export cssColour names

* remove import

* only allow string types to colour

* handle transparent colour

* mix alpha with bg colour

* only allow updating events

* descriptive names

* add test for getAccessibleColour

* readability

* move isColourHex to regex-utils

* simplify and add test
2023-12-08 12:55:04 +01:00

46 lines
1.1 KiB
TypeScript

import { isColourHex } from './isColourHex';
describe('test isColourHex() function', () => {
it('it validates colour hex strings', () => {
const ts = ['#FFF', '#FFFF', '#FFFFFF', '#FFFFFFFF'];
for (const s of ts) {
expect(isColourHex(s)).toBe(true);
}
});
it('it validates colour hex strings', () => {
const ts = ['#F90', '#1234', '#56789A', '#BCDEF012'];
for (const s of ts) {
expect(isColourHex(s)).toBe(true);
}
});
it('it validates colour hex strings', () => {
const ts = ['#f90', '#1234', '#56789a', '#bcdef012'];
for (const s of ts) {
expect(isColourHex(s)).toBe(true);
}
});
it('it fails digits bigger than F', () => {
const ts = ['#FFG'];
for (const s of ts) {
expect(isColourHex(s)).toBe(false);
}
});
it('it fails incorect amout of digits', () => {
const ts = ['#F', '#FF', '#FFFFF', '#FFFFFFF', '#FFFFFFFFF'];
for (const s of ts) {
expect(isColourHex(s)).toBe(false);
}
});
it('it fails missing #', () => {
const ts = ['FFF', 'FFFF', 'FFFFFF', 'FFFFFFFF'];
for (const s of ts) {
expect(isColourHex(s)).toBe(false);
}
});
});