Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests/ roosterjs-react #2524

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
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();
});
});