Added test covering ColorGenerator.isColorLightForKey

This commit is contained in:
Alejandro Celaya 2022-01-08 12:16:31 +01:00
parent b727a704a6
commit aca9218f9d

View file

@ -44,4 +44,19 @@ describe('ColorGenerator', () => {
expect(storageMock.set).toHaveBeenCalledTimes(1);
expect(storageMock.get).toHaveBeenCalledTimes(1);
});
describe('isColorLightForKey', () => {
it.each([
[ '#4696e5', true ], // Shlink brand color
[ '#8A661C', false ],
[ '#F7BE05', true ],
[ '#5A02D8', false ],
[ '#202786', false ],
])('returns that the color for a key is light based on the color assigned to that key', (color, isLight) => {
colorGenerator.setColorForKey('foo', color);
expect(isLight).toEqual(colorGenerator.isColorLightForKey('foo'));
expect(isLight).toEqual(colorGenerator.isColorLightForKey('foo')); // To cover when color is already calculated
});
});
});