43 lines
1.4 KiB
TypeScript
43 lines
1.4 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"]);
|
|
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);
|
|
});
|
|
});
|