Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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();
});
});
24 changes: 24 additions & 0 deletions packages/roosterjs-react/test/colorPicker/utils/textColorsTest.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});