40 lines
1.2 KiB
TypeScript
40 lines
1.2 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);
|
|
}
|
|
}
|
|
});
|
|
});
|