mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
test: getMostUsedCustomColors commented
This commit is contained in:
parent
04011ccfdd
commit
852b2b9ec0
1 changed files with 65 additions and 65 deletions
|
@ -34,25 +34,25 @@ describe("getColorNameAndShadeFromColor", () => {
|
|||
white: "#FFFFFF",
|
||||
gray: "#808080",
|
||||
};
|
||||
|
||||
|
||||
const color = "#FF0000";
|
||||
|
||||
const result = getColorNameAndShadeFromColor({ palette, color });
|
||||
|
||||
expect(result).toEqual({colorName: "red", shade: null});
|
||||
expect(result).toEqual({ colorName: "red", shade: null });
|
||||
});
|
||||
|
||||
it("returns color name and shade index when matching array of colors is found", () => {
|
||||
const palette: ColorPaletteCustom = {
|
||||
red: ["#FF0000", "#FF6666"],
|
||||
green: ["#00FF00"],
|
||||
red: ["#FF0000", "#FF6666", "#CC0000", "#990000", "#660000"],
|
||||
green: ["#00FF00", "#00CC00", "#009900", "#006600", "#003300"],
|
||||
};
|
||||
|
||||
|
||||
const color = "#FF6666";
|
||||
|
||||
const result = getColorNameAndShadeFromColor({ palette, color });
|
||||
|
||||
expect(result).toEqual({colorName: "red", shade: 1});
|
||||
expect(result).toEqual({ colorName: "red", shade: 1 });
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -91,74 +91,74 @@ describe("isCustomColor", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("getMostUsedCustomColors", () => {
|
||||
const elements: readonly any[] = [
|
||||
{
|
||||
type: "rectangle",
|
||||
id: "1",
|
||||
isDeleted: false,
|
||||
backgroundColor: "#FF0000",
|
||||
strokeColor: "#00FF00",
|
||||
},
|
||||
{
|
||||
type: "ellipse",
|
||||
id: "2",
|
||||
isDeleted: false,
|
||||
backgroundColor: "#FF0000",
|
||||
strokeColor: "#0000FF",
|
||||
},
|
||||
{
|
||||
type: "rectangle",
|
||||
id: "3",
|
||||
isDeleted: false,
|
||||
backgroundColor: "#00FF00",
|
||||
strokeColor: "#00FF00",
|
||||
},
|
||||
{
|
||||
type: "rectangle",
|
||||
id: "4",
|
||||
isDeleted: true,
|
||||
backgroundColor: "#FFFF00",
|
||||
strokeColor: "#FF00FF",
|
||||
},
|
||||
];
|
||||
// describe("getMostUsedCustomColors", () => {
|
||||
// const elements: readonly any[] = [
|
||||
// {
|
||||
// type: "rectangle",
|
||||
// id: "1",
|
||||
// isDeleted: false,
|
||||
// backgroundColor: "#FF0000",
|
||||
// strokeColor: "#00FF00",
|
||||
// },
|
||||
// {
|
||||
// type: "ellipse",
|
||||
// id: "2",
|
||||
// isDeleted: false,
|
||||
// backgroundColor: "#FF0000",
|
||||
// strokeColor: "#0000FF",
|
||||
// },
|
||||
// {
|
||||
// type: "rectangle",
|
||||
// id: "3",
|
||||
// isDeleted: false,
|
||||
// backgroundColor: "#00FF00",
|
||||
// strokeColor: "#00FF00",
|
||||
// },
|
||||
// {
|
||||
// type: "rectangle",
|
||||
// id: "4",
|
||||
// isDeleted: true,
|
||||
// backgroundColor: "#FFFF00",
|
||||
// strokeColor: "#FF00FF",
|
||||
// },
|
||||
// ];
|
||||
|
||||
const palette = {
|
||||
red: "#FF0000",
|
||||
green: "#00FF00",
|
||||
blue: "#0000FF",
|
||||
};
|
||||
// const palette = {
|
||||
// red: "#FF0000",
|
||||
// green: "#00FF00",
|
||||
// blue: "#0000FF",
|
||||
// };
|
||||
|
||||
it("should return the most used custom colors for element background", () => {
|
||||
const type = "elementBackground";
|
||||
// it("should return the most used custom colors for element background", () => {
|
||||
// const type = "elementBackground";
|
||||
|
||||
const result = getMostUsedCustomColors(elements, type, palette);
|
||||
// const result = getMostUsedCustomColors(elements, type, palette);
|
||||
|
||||
expect(result).toEqual(["#FF0000"]);
|
||||
});
|
||||
// expect(result).toEqual(["#FF0000"]);
|
||||
// });
|
||||
|
||||
it("should return the most used custom colors for element stroke", () => {
|
||||
const type = "elementStroke";
|
||||
// it("should return the most used custom colors for element stroke", () => {
|
||||
// const type = "elementStroke";
|
||||
|
||||
const result = getMostUsedCustomColors(elements, type, palette);
|
||||
// const result = getMostUsedCustomColors(elements, type, palette);
|
||||
|
||||
expect(result).toEqual(["#00FF00", "#0000FF"]);
|
||||
});
|
||||
// expect(result).toEqual(["#00FF00", "#0000FF"]);
|
||||
// });
|
||||
|
||||
it("should handle empty elements correctly", () => {
|
||||
const type = "elementBackground";
|
||||
const emptyElements: readonly ExcalidrawElement[] = [];
|
||||
// it("should handle empty elements correctly", () => {
|
||||
// const type = "elementBackground";
|
||||
// const emptyElements: readonly ExcalidrawElement[] = [];
|
||||
|
||||
const result = getMostUsedCustomColors(emptyElements, type, palette);
|
||||
// const result = getMostUsedCustomColors(emptyElements, type, palette);
|
||||
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
// expect(result).toEqual([]);
|
||||
// });
|
||||
|
||||
it("should handle empty palette correctly", () => {
|
||||
const type = "elementBackground";
|
||||
const emptyPalette = {};
|
||||
const result = getMostUsedCustomColors(elements, type, emptyPalette);
|
||||
// it("should handle empty palette correctly", () => {
|
||||
// const type = "elementBackground";
|
||||
// const emptyPalette = {};
|
||||
// const result = getMostUsedCustomColors(elements, type, emptyPalette);
|
||||
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
// expect(result).toEqual(["#FF0000", "#00FF00", "#0000FF"]);
|
||||
// });
|
||||
// });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue