mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
test : resolved comments & modified code
This commit is contained in:
parent
451f8034c7
commit
4e454b41d1
2 changed files with 32 additions and 34 deletions
32
src/components/ColorPicker/colorPicker.test.ts
Normal file
32
src/components/ColorPicker/colorPicker.test.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { ColorPaletteCustom } from "../../colors";
|
||||
import {
|
||||
getColorNameAndShadeFromColor,
|
||||
colorPickerHotkeyBindings,
|
||||
} from "./colorPickerUtils";
|
||||
|
||||
describe("getColorNameAndShadeFromColor", () => {
|
||||
it("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", () => {
|
||||
it("should contain all the expected hotkey bindings", () => {
|
||||
|
||||
const testBindingKeys = [
|
||||
["q", "w", "e", "r", "t"],
|
||||
["a", "s", "d", "f", "g"],
|
||||
["z", "x", "c", "v", "b"],
|
||||
].flat();
|
||||
|
||||
expect(testBindingKeys).toEqual(colorPickerHotkeyBindings);
|
||||
});
|
||||
});
|
|
@ -1,34 +0,0 @@
|
|||
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