deadhead-space-freight-tycoon/packages/content/test/locations.test.ts

46 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { cargoTypes, locationSchema, locations } from "../src/index";
const cargoTypeIds = cargoTypes.map((c) => c.id);
describe("locations", () => {
it("all pass the schema", () => {
for (const location of locations) {
expect(() => locationSchema.parse(location)).not.toThrow();
}
});
it("has exactly five locations with unique ids", () => {
expect(locations).toHaveLength(5);
expect(new Set(locations.map((l) => l.id)).size).toBe(5);
});
it("starts with exactly Earth and Moon discovered", () => {
const discovered = locations.filter((l) => l.startsDiscovered).map((l) => l.id);
expect(discovered.sort()).toEqual(["earth", "moon"]);
});
it("references only existing cargo types", () => {
for (const location of locations) {
for (const cargoId of [...location.produces, ...location.demands]) {
expect(cargoTypeIds).toContain(cargoId);
}
}
});
it("gives Earth the highest launch multiplier", () => {
const earth = locations.find((l) => l.id === "earth")!;
for (const location of locations) {
if (location !== earth) {
expect(earth.launchCostMultiplier).toBeGreaterThan(location.launchCostMultiplier);
}
}
});
it("gives every location its own map sprite key (CR-003)", () => {
const sprites = locations.map((x) => x.sprite);
for (const sprite of sprites) expect(sprite).toMatch(/^[a-z][a-z-]*$/);
expect(new Set(sprites).size).toBe(sprites.length);
});
});