53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { cargoTypes, goods, 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 goods, and cargo classes in its class mix", () => {
|
|
const goodIds = goods.map((g) => g.id);
|
|
for (const location of locations) {
|
|
for (const goodId of [...location.produces, ...location.demands]) {
|
|
expect(goodIds).toContain(goodId);
|
|
}
|
|
const { produces, demands } = location.cargoClassMix;
|
|
for (const cargoId of [...produces, ...demands]) expect(cargoTypeIds).toContain(cargoId);
|
|
}
|
|
});
|
|
|
|
it("has at least one shipper per location (CR-007)", () => {
|
|
for (const location of locations) expect(location.shippers.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|