| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | import { PROJECT_ICON_COLORS } from "./projectIconColors"; |
| 3 | import { deriveProjectIdentity } from "./projectIdentity"; |
| 4 | |
| 5 | describe("deriveProjectIdentity", () => { |
| 6 | it.each([ |
| 7 | ["Nebula", "NA"], |
| 8 | ["Silver Orchard", "SO"], |
| 9 | ["Quiet Lantern Workshop", "QW"], |
| 10 | ["m7forge", "M7"], |
| 11 | ["M7 Forge", "M7"], |
| 12 | ["X", "XX"], |
| 13 | ["---", "PR"], |
| 14 | ])("derives %s as %s", (projectName, expected) => { |
| 15 | expect(deriveProjectIdentity(projectName).monogram).toBe(expected); |
| 16 | }); |
| 17 | |
| 18 | it("keeps the palette stable across case and surrounding whitespace", () => { |
| 19 | const canonical = deriveProjectIdentity("Nebula"); |
| 20 | const equivalent = deriveProjectIdentity(" NEBULA "); |
| 21 | |
| 22 | expect(equivalent.color).toBe(canonical.color); |
| 23 | }); |
| 24 | |
| 25 | it("uses only colors available in the icon picker", () => { |
| 26 | const palette = PROJECT_ICON_COLORS.map(({ value }) => value); |
| 27 | for (const name of ["Jobs", "Scripts and Extractors", "T3", "文書", "", "---"]) { |
| 28 | expect(palette).toContain(deriveProjectIdentity(name).color); |
| 29 | } |
| 30 | }); |
| 31 | |
| 32 | it("generates different hues for different project names", () => { |
| 33 | const colors = new Set( |
| 34 | ["Nebula", "M7 Forge", "Silver Orchard", "Blue Harbor", "Copper Finch", "Juniper Vale"].map( |
| 35 | (projectName) => deriveProjectIdentity(projectName).color, |
| 36 | ), |
| 37 | ); |
| 38 | |
| 39 | expect(colors.size).toBeGreaterThan(1); |
| 40 | }); |
| 41 | }); |