catppuccin-palette/mod.test.ts

86 lines
2.3 KiB
TypeScript
Raw Normal View History

2023-12-28 10:43:11 +00:00
import { assertEquals } from "std/assert/assert_equals.ts";
import { flavorEntries, flavors, version } from "@catppuccin/palette";
import palette from "@/palette.json" with { type: "json" };
2023-12-28 10:43:11 +00:00
Deno.test("flavorEntries", () => {
flavorEntries.map(([flavorName, flavor]) => {
flavor.colorEntries.map(([colorName, color]) =>
assertEquals(color.hex, palette[flavorName].colors[colorName].hex)
2023-12-28 10:43:11 +00:00
);
});
2023-12-28 10:43:11 +00:00
});
Deno.test("flavors", () => {
flavorEntries.map(([flavorName]) => {
assertEquals(flavors[flavorName].name, palette[flavorName].name);
});
});
Deno.test("ansiEntries", () => {
flavorEntries.map(([flavorName, flavor]) => {
flavor.ansiColorEntries.map(([ansiColorName, ansiColor]) => {
assertEquals(
ansiColor.normal.name,
ansiColor.name
);
assertEquals(
ansiColor.bright.name,
`Bright ${ansiColor.name}`
);
assertEquals(
ansiColor.normal.hex,
palette[flavorName].ansiColors[ansiColorName].normal.hex,
);
if (ansiColorName == "black") {
if (flavorName == "latte") {
assertEquals(
ansiColor.normal.hex,
palette[flavorName].colors.subtext1.hex,
);
assertEquals(
ansiColor.bright.hex,
palette[flavorName].colors.subtext0.hex,
);
} else {
assertEquals(
ansiColor.normal.hex,
palette[flavorName].colors.surface1.hex,
);
assertEquals(
ansiColor.bright.hex,
palette[flavorName].colors.surface2.hex,
);
}
}
if (ansiColorName == "white") {
if (flavorName == "latte") {
assertEquals(
ansiColor.normal.hex,
palette[flavorName].colors.surface2.hex,
);
assertEquals(
ansiColor.bright.hex,
palette[flavorName].colors.surface1.hex,
);
} else {
assertEquals(
ansiColor.normal.hex,
palette[flavorName].colors.subtext0.hex,
);
assertEquals(
ansiColor.bright.hex,
palette[flavorName].colors.subtext1.hex,
);
}
}
});
2023-12-28 10:43:11 +00:00
});
});
Deno.test("version", () => {
assertEquals(version, "1.7.1"); // x-release-please-version
});