mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
test: fixed failing test per original code
This commit is contained in:
parent
0914c08add
commit
08eea53211
1 changed files with 63 additions and 60 deletions
|
@ -1,6 +1,8 @@
|
||||||
import { ColorPaletteCustom } from "../../colors";
|
import { ColorPaletteCustom } from "../../colors";
|
||||||
|
import { ExcalidrawElement } from "../../element/types";
|
||||||
import {
|
import {
|
||||||
getColorNameAndShadeFromColor,
|
getColorNameAndShadeFromColor,
|
||||||
|
getMostUsedCustomColors,
|
||||||
isCustomColor,
|
isCustomColor,
|
||||||
} from "./colorPickerUtils";
|
} from "./colorPickerUtils";
|
||||||
|
|
||||||
|
@ -89,76 +91,77 @@ describe("isCustomColor", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME: temporary commented below test because they're failing
|
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 palette = {
|
||||||
// const elements: readonly any[] = [
|
red: "#FF0000",
|
||||||
// {
|
green: "#00FF00",
|
||||||
// type: "rectangle",
|
blue: "#0000FF",
|
||||||
// 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 = {
|
it("should return empty array for elementBackground.", () => {
|
||||||
// red: "#FF0000",
|
const type = "elementBackground";
|
||||||
// green: "#00FF00",
|
|
||||||
// blue: "#0000FF",
|
|
||||||
// };
|
|
||||||
|
|
||||||
// it("should return the most used custom colors for element background", () => {
|
const result = getMostUsedCustomColors(elements, type, palette);
|
||||||
// const type = "elementBackground";
|
|
||||||
|
|
||||||
// const result = getMostUsedCustomColors(elements, type, palette);
|
expect(result).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
// expect(result).toEqual(["#FF0000"]);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// it("should return the most used custom colors for element stroke", () => {
|
it("should return empty array for elementStroke.", () => {
|
||||||
// const type = "elementStroke";
|
const type = "elementStroke";
|
||||||
|
|
||||||
// const result = getMostUsedCustomColors(elements, type, palette);
|
const result = getMostUsedCustomColors(elements, type, palette);
|
||||||
|
|
||||||
// expect(result).toEqual(["#00FF00", "#0000FF"]);
|
expect(result).toEqual([]);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// it("should handle empty elements correctly", () => {
|
|
||||||
// const type = "elementBackground";
|
|
||||||
// const emptyElements: readonly ExcalidrawElement[] = [];
|
|
||||||
|
|
||||||
// const result = getMostUsedCustomColors(emptyElements, type, palette);
|
it("should handle empty elements correctly", () => {
|
||||||
|
const type = "elementBackground";
|
||||||
|
const emptyElements: readonly ExcalidrawElement[] = [];
|
||||||
|
|
||||||
// expect(result).toEqual([]);
|
const result = getMostUsedCustomColors(emptyElements, type, palette);
|
||||||
// });
|
|
||||||
|
|
||||||
// it("should handle empty palette correctly", () => {
|
expect(result).toEqual([]);
|
||||||
// const type = "elementBackground";
|
});
|
||||||
// const emptyPalette = {};
|
|
||||||
// const result = getMostUsedCustomColors(elements, type, emptyPalette);
|
|
||||||
|
|
||||||
// expect(result).toEqual(["#FF0000", "#00FF00", "#0000FF"]);
|
it("should handle empty palette correctly", () => {
|
||||||
// });
|
const type = "elementBackground";
|
||||||
// });
|
const emptyPalette = {};
|
||||||
|
const result = getMostUsedCustomColors(elements, type, emptyPalette);
|
||||||
|
|
||||||
|
// Assuming MAX_CUSTOM_COLORS_USED_IN_CANVAS is set to 2
|
||||||
|
expect(result).toEqual(["#FF0000", "#00FF00"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue