From aca9218f9d1fae3ff86625f23cf6fadbd4f4fd85 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 8 Jan 2022 12:16:31 +0100 Subject: [PATCH] Added test covering ColorGenerator.isColorLightForKey --- test/utils/services/ColorGenerator.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/utils/services/ColorGenerator.test.ts b/test/utils/services/ColorGenerator.test.ts index 990b268e..b2d435ce 100644 --- a/test/utils/services/ColorGenerator.test.ts +++ b/test/utils/services/ColorGenerator.test.ts @@ -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 + }); + }); });