1
0
Fork 0
polaris-task-force/tests/int/blackjack-card-skins.int.spec.ts
Z8MB1E 474aff734d feat(blackjack): add blackjack minigame with realtime table wiring
Engine, felt, controls, sounds, card skins, and dev popups; SSE events in the realtime hook, nav and command palette entries, stats migration, and the six blackjack test suites.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-09-14 15:38:05 -04:00

45 lines
2.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { Card } from "@/lib/minigames/blackjack";
import { mapCardToSvg, normalizeCardStyle } from "@/components/frontend/minigames/blackjack/cardStyle";
function cardOf(rank: Card["rank"], suit: Card["suit"]): Card {
return { rank, suit };
}
describe("mapCardToSvg", () => {
it("maps number cards to their numbered asset path", () => {
expect(mapCardToSvg(cardOf(7, "h"))).toBe("/images/assets/playing-cards/7_of_hearts.svg");
expect(mapCardToSvg(cardOf(10, "s"))).toBe("/images/assets/playing-cards/10_of_spades.svg");
expect(mapCardToSvg(cardOf(2, "c"))).toBe("/images/assets/playing-cards/2_of_clubs.svg");
});
it("maps face ranks to word asset paths", () => {
expect(mapCardToSvg(cardOf(11, "d"))).toBe("/images/assets/playing-cards/jack_of_diamonds.svg");
expect(mapCardToSvg(cardOf(12, "c"))).toBe("/images/assets/playing-cards/queen_of_clubs.svg");
expect(mapCardToSvg(cardOf(13, "h"))).toBe("/images/assets/playing-cards/king_of_hearts.svg");
expect(mapCardToSvg(cardOf(14, "s"))).toBe("/images/assets/playing-cards/ace_of_spades.svg");
});
it("covers all four suits for a spot-check rank", () => {
expect(mapCardToSvg(cardOf(9, "s"))).toBe("/images/assets/playing-cards/9_of_spades.svg");
expect(mapCardToSvg(cardOf(9, "h"))).toBe("/images/assets/playing-cards/9_of_hearts.svg");
expect(mapCardToSvg(cardOf(9, "d"))).toBe("/images/assets/playing-cards/9_of_diamonds.svg");
expect(mapCardToSvg(cardOf(9, "c"))).toBe("/images/assets/playing-cards/9_of_clubs.svg");
});
});
describe("normalizeCardStyle", () => {
it("accepts the three known style values", () => {
expect(normalizeCardStyle("light")).toBe("light");
expect(normalizeCardStyle("dark")).toBe("dark");
expect(normalizeCardStyle("classic")).toBe("classic");
});
it("falls back to light for unknown or missing values", () => {
expect(normalizeCardStyle("bogus")).toBe("light");
expect(normalizeCardStyle(null)).toBe("light");
expect(normalizeCardStyle(undefined)).toBe("light");
expect(normalizeCardStyle(42)).toBe("light");
expect(normalizeCardStyle("")).toBe("light");
});
});