test : added test for colorPickerHotkeyBindings

This commit is contained in:
Dinesh Katariya 2023-06-06 22:09:41 +05:30
parent 09426e3aac
commit 451f8034c7
2 changed files with 34 additions and 17 deletions

View file

@ -1,17 +0,0 @@
import { ColorPaletteCustom } from '../../colors';
import { getColorNameAndShadeFromColor } from './colorPickerUtils';
test('getColorNameAndShadeFromColor returns null when no matching color is found', () => {
// Arrange
const palette: ColorPaletteCustom = {
green: '#00FF00',
orange: '#E07C24',
};
const color = '#FF6666';
// Act
const result = getColorNameAndShadeFromColor({ palette, color });
// Assert
expect(result).toBeNull();
});

View file

@ -0,0 +1,34 @@
import { ColorPaletteCustom } from "../../colors";
import {
getColorNameAndShadeFromColor,
colorPickerHotkeyBindings,
} from "./colorPickerUtils";
import { render, screen } from "@testing-library/react";
test("getColorNameAndShadeFromColor returns null when no matching color is found", () => {
const palette: ColorPaletteCustom = {
green: "#00FF00",
orange: "#E07C24",
};
const color = "#FF6666";
const result = getColorNameAndShadeFromColor({ palette, color });
expect(result).toBeNull();
});
describe('colorPickerHotkeyBindings', () => {
test('renders all hotkey bindings', () => {
render(
<div>
<h1>{colorPickerHotkeyBindings.join(',')}</h1>
</div>
);
colorPickerHotkeyBindings.forEach((hotkey) => {
const hotkeyElement = screen.getByText(hotkey);
expect(hotkeyElement).toBeInTheDocument();
});
});
});