deadhead-space-freight-tycoon/apps/web/test/map-style.test.ts

35 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from "vitest";
import { mapStyle, mapStyleSchema } from "../src/map/style";
describe("map style config (CR-003)", () => {
it("validates", () => {
expect(mapStyleSchema.safeParse(mapStyle).success).toBe(true);
});
it("rejects non-positive sizes, min scale above max, and parallax outside 0–1", () => {
const bad = [
{ ...mapStyle, shipSizePx: 0 },
{ ...mapStyle, spriteSizePx: { ...mapStyle.spriteSizePx, sun: -1 } },
{ ...mapStyle, minTapPx: 0 },
{ ...mapStyle, spriteScale: { min: 2, max: 1 } },
{ ...mapStyle, parallax: 1.5 },
{ ...mapStyle, parallax: -0.1 },
];
for (const style of bad) expect(mapStyleSchema.safeParse(style).success).toBe(false);
});
it("sizes every body sprite and keeps tap targets at least 44 px", () => {
for (const id of [
"sun",
"body-earth",
"body-moon",
"body-mars",
"body-ceres",
"body-jupiter",
]) {
expect(mapStyle.spriteSizePx[id], id).toBeGreaterThan(0);
}
expect(mapStyle.minTapPx).toBeGreaterThanOrEqual(44);
});
});