mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
test : added test for colorPickerHotkeyBindings
This commit is contained in:
parent
09426e3aac
commit
451f8034c7
2 changed files with 34 additions and 17 deletions
|
@ -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();
|
||||
});
|
34
src/components/ColorPicker/colorPicker.test.tsx
Normal file
34
src/components/ColorPicker/colorPicker.test.tsx
Normal 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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue