54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { shipModelSchema, shipModels } from "../src/index";
|
|
|
|
const ship = (id: string) => shipModels.find((s) => s.id === id)!;
|
|
|
|
describe("ship models", () => {
|
|
it("all pass the schema", () => {
|
|
for (const model of shipModels) {
|
|
expect(() => shipModelSchema.parse(model)).not.toThrow();
|
|
}
|
|
});
|
|
|
|
it("has the three archetypes, all atmospheric", () => {
|
|
expect(shipModels.map((s) => s.id)).toEqual([
|
|
"courier",
|
|
"freighter",
|
|
"bulk-hauler",
|
|
"company-courier",
|
|
]);
|
|
for (const model of shipModels) {
|
|
expect(model.landingClass).toBe("atmospheric");
|
|
}
|
|
});
|
|
|
|
it("orders speed Courier > Freighter > Bulk Hauler", () => {
|
|
expect(ship("courier").cruiseSpeedKmPerGameHour).toBeGreaterThan(
|
|
ship("freighter").cruiseSpeedKmPerGameHour,
|
|
);
|
|
expect(ship("freighter").cruiseSpeedKmPerGameHour).toBeGreaterThan(
|
|
ship("bulk-hauler").cruiseSpeedKmPerGameHour,
|
|
);
|
|
});
|
|
|
|
it("orders capacity Bulk Hauler > Freighter > Courier", () => {
|
|
expect(ship("bulk-hauler").cargoCapacityTonnes).toBeGreaterThan(
|
|
ship("freighter").cargoCapacityTonnes,
|
|
);
|
|
expect(ship("freighter").cargoCapacityTonnes).toBeGreaterThan(
|
|
ship("courier").cargoCapacityTonnes,
|
|
);
|
|
});
|
|
|
|
it("orders price Courier < Freighter < Bulk Hauler", () => {
|
|
expect(ship("courier").price).toBeLessThan(ship("freighter").price);
|
|
expect(ship("freighter").price).toBeLessThan(ship("bulk-hauler").price);
|
|
});
|
|
|
|
it("gives every ship model its own map sprite key (CR-003)", () => {
|
|
const sprites = shipModels.map((x) => x.sprite);
|
|
for (const sprite of sprites) expect(sprite).toMatch(/^[a-z][a-z-]*$/);
|
|
expect(new Set(sprites).size).toBe(sprites.length);
|
|
});
|
|
});
|