diff --git a/packages/roosterjs-react/test/colorPicker/utils/backgroundColorsTest.ts b/packages/roosterjs-react/test/colorPicker/utils/backgroundColorsTest.ts new file mode 100644 index 00000000000..20422d14023 --- /dev/null +++ b/packages/roosterjs-react/test/colorPicker/utils/backgroundColorsTest.ts @@ -0,0 +1,25 @@ +import { BackgroundColorKeys } from 'roosterjs-react'; +import { + BackgroundColorDropDownItems, + BackgroundColors, + getBackgroundColorValue, +} from '../../../lib/colorPicker/utils/backgroundColors'; + +describe('getBackgroundColorValue', () => { + it('returns the value of each key in TextColors', () => { + Object.keys(BackgroundColorDropDownItems).forEach(key => { + const output = getBackgroundColorValue(key as BackgroundColorKeys); + const expectedOutput = BackgroundColors[key]; + + expect(output.lightModeColor).toBe(expectedOutput.lightModeColor); + expect(output.darkModeColor).toBe(expectedOutput.darkModeColor); + }); + }); + + it('throws an error for none existing key', () => { + const invalidKey = 'invalidKey'; + const output = getBackgroundColorValue(invalidKey as BackgroundColorKeys); + + expect(output).toBeUndefined(); + }); +}); diff --git a/packages/roosterjs-react/test/colorPicker/utils/textColorsTest.ts b/packages/roosterjs-react/test/colorPicker/utils/textColorsTest.ts new file mode 100644 index 00000000000..6f4a821ca0a --- /dev/null +++ b/packages/roosterjs-react/test/colorPicker/utils/textColorsTest.ts @@ -0,0 +1,24 @@ +import { TextColorKeys } from 'roosterjs-react'; +import { + getTextColorValue, + TextColorDropDownItems, + TextColors, +} from '../../../lib/colorPicker/utils/textColors'; + +describe('getTextColorValue', () => { + it('returns the value of each key in TextColors', () => { + Object.keys(TextColorDropDownItems).forEach(key => { + const output = getTextColorValue(key as TextColorKeys); + const expectedOutput = TextColors[key]; + + expect(output.lightModeColor).toBe(expectedOutput.lightModeColor); + expect(output.darkModeColor).toBe(expectedOutput.darkModeColor); + }); + }); + + it('throws an error for none existing key', () => { + const invalidKey = 'invalidKey'; + const output = getTextColorValue(invalidKey as TextColorKeys); + expect(output).toBeUndefined(); + }); +});