mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 09:23:51 +00:00
1343818917
* 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
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { cx, getAccessibleColour } from '../styleUtils';
|
|
|
|
import style from './styleUtils.module.scss';
|
|
|
|
describe('cx()', () => {
|
|
it('merges styles', () => {
|
|
const merged = cx([style.test, style.another]);
|
|
expect(merged).toMatchSnapshot();
|
|
});
|
|
it('ignores falsy values', () => {
|
|
const falsyStuff = false;
|
|
const merged = cx([undefined, false, 0, null, falsyStuff ? style.test : null]);
|
|
expect(merged).toMatchSnapshot();
|
|
});
|
|
});
|
|
|
|
describe('getAccessibleColour()', () => {
|
|
it('handles named colours', () => {
|
|
const colour = 'red';
|
|
const { backgroundColor, color } = getAccessibleColour(colour);
|
|
expect(backgroundColor).toBe('#FF0000FF');
|
|
expect(color).toBe('#fffffa');
|
|
});
|
|
it('handles hex colours', () => {
|
|
const colour = '#0F0';
|
|
const { backgroundColor, color } = getAccessibleColour(colour);
|
|
expect(backgroundColor).toBe('#00FF00FF');
|
|
expect(color).toBe('black');
|
|
});
|
|
it('handles transparens', () => {
|
|
const colour = '#0F08';
|
|
const { backgroundColor, color } = getAccessibleColour(colour);
|
|
expect(backgroundColor).toBe('#0C940CFF');
|
|
expect(color).toBe('#fffffa');
|
|
});
|
|
});
|