forked from mirrored/github-readme-stats
77 lines
1.9 KiB
JavaScript
77 lines
1.9 KiB
JavaScript
import { getCardColors } from "../src/common/color";
|
|
import { describe, expect, it } from "@jest/globals";
|
|
|
|
describe("Test color.js", () => {
|
|
it("getCardColors: should return expected values", () => {
|
|
let colors = getCardColors({
|
|
title_color: "f00",
|
|
text_color: "0f0",
|
|
ring_color: "0000ff",
|
|
icon_color: "00f",
|
|
bg_color: "fff",
|
|
border_color: "fff",
|
|
theme: "dark",
|
|
});
|
|
expect(colors).toStrictEqual({
|
|
titleColor: "#f00",
|
|
textColor: "#0f0",
|
|
iconColor: "#00f",
|
|
ringColor: "#0000ff",
|
|
bgColor: "#fff",
|
|
borderColor: "#fff",
|
|
});
|
|
});
|
|
|
|
it("getCardColors: should fallback to default colors if color is invalid", () => {
|
|
let colors = getCardColors({
|
|
title_color: "invalidcolor",
|
|
text_color: "0f0",
|
|
icon_color: "00f",
|
|
bg_color: "fff",
|
|
border_color: "invalidColor",
|
|
theme: "dark",
|
|
});
|
|
expect(colors).toStrictEqual({
|
|
titleColor: "#2f80ed",
|
|
textColor: "#0f0",
|
|
iconColor: "#00f",
|
|
ringColor: "#2f80ed",
|
|
bgColor: "#fff",
|
|
borderColor: "#e4e2e2",
|
|
});
|
|
});
|
|
|
|
it("getCardColors: should fallback to specified theme colors if is not defined", () => {
|
|
let colors = getCardColors({
|
|
theme: "dark",
|
|
});
|
|
expect(colors).toStrictEqual({
|
|
titleColor: "#fff",
|
|
textColor: "#9f9f9f",
|
|
ringColor: "#fff",
|
|
iconColor: "#79ff97",
|
|
bgColor: "#151515",
|
|
borderColor: "#e4e2e2",
|
|
});
|
|
});
|
|
|
|
it("getCardColors: should return ring color equal to title color if not ring color is defined", () => {
|
|
let colors = getCardColors({
|
|
title_color: "f00",
|
|
text_color: "0f0",
|
|
icon_color: "00f",
|
|
bg_color: "fff",
|
|
border_color: "fff",
|
|
theme: "dark",
|
|
});
|
|
expect(colors).toStrictEqual({
|
|
titleColor: "#f00",
|
|
textColor: "#0f0",
|
|
iconColor: "#00f",
|
|
ringColor: "#f00",
|
|
bgColor: "#fff",
|
|
borderColor: "#fff",
|
|
});
|
|
});
|
|
});
|