35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
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, zoomExponent: 0.35 } },
|
||
{ ...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);
|
||
});
|
||
});
|