56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { cargoTypeSchema, cargoTypes, skillSchema, skills } from "../src/index";
|
|
|
|
describe("cargo types", () => {
|
|
it("all pass the schema", () => {
|
|
for (const cargo of cargoTypes) {
|
|
expect(() => cargoTypeSchema.parse(cargo)).not.toThrow();
|
|
}
|
|
});
|
|
|
|
it("has Standard plus three skill-gated types", () => {
|
|
expect(cargoTypes.map((c) => c.id)).toEqual(["standard", "heavy", "high-value", "dangerous"]);
|
|
expect(cargoTypes.find((c) => c.id === "standard")!.requiredSkillId).toBeNull();
|
|
});
|
|
|
|
it("requires only skills that exist", () => {
|
|
const skillIds = skills.map((s) => s.id);
|
|
for (const cargo of cargoTypes) {
|
|
if (cargo.requiredSkillId !== null) {
|
|
expect(skillIds).toContain(cargo.requiredSkillId);
|
|
}
|
|
}
|
|
});
|
|
|
|
it("pays more than Standard for every non-standard type", () => {
|
|
const standard = cargoTypes.find((c) => c.id === "standard")!;
|
|
for (const cargo of cargoTypes) {
|
|
if (cargo !== standard) {
|
|
expect(cargo.basePayPerTonnePerMillionKm).toBeGreaterThan(
|
|
standard.basePayPerTonnePerMillionKm,
|
|
);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("skills", () => {
|
|
it("all pass the schema", () => {
|
|
for (const skill of skills) {
|
|
expect(() => skillSchema.parse(skill)).not.toThrow();
|
|
}
|
|
});
|
|
|
|
it("has the four base skills, each max level 5", () => {
|
|
expect(skills.map((s) => s.id)).toEqual([
|
|
"long-haul",
|
|
"heavy-cargo",
|
|
"expensive-cargo",
|
|
"dangerous-cargo",
|
|
]);
|
|
for (const skill of skills) {
|
|
expect(skill.maxLevel).toBe(5);
|
|
}
|
|
});
|
|
});
|