55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { checkPilotEligibility, type Contract } from "../src/index";
|
|
|
|
const shortStandard: Contract = {
|
|
id: "c1",
|
|
originId: "earth",
|
|
destinationId: "moon",
|
|
cargoTypeId: "standard",
|
|
tier: 0,
|
|
massTonnes: 10,
|
|
payout: 1000,
|
|
requiredSkill: null,
|
|
requiredLongHaulLevel: 0,
|
|
offeredAt: 0,
|
|
expiresAt: 3_600_000,
|
|
firstContact: false,
|
|
};
|
|
const heavyTier2: Contract = {
|
|
...shortStandard,
|
|
cargoTypeId: "heavy",
|
|
tier: 2,
|
|
requiredSkill: { skillId: "heavy-cargo", level: 2 },
|
|
};
|
|
const longRoute: Contract = {
|
|
...shortStandard,
|
|
destinationId: "ceres-station",
|
|
requiredLongHaulLevel: 1,
|
|
};
|
|
|
|
describe("pilot eligibility", () => {
|
|
it("lets a level-0 pilot take a short Standard contract", () => {
|
|
expect(checkPilotEligibility({}, shortStandard)).toEqual({ ok: true });
|
|
});
|
|
|
|
it("stops a level-0 pilot from taking a Heavy contract needing Heavy Cargo 2", () => {
|
|
expect(checkPilotEligibility({}, heavyTier2)).toEqual({
|
|
ok: false,
|
|
reason: "cargo-skill-too-low",
|
|
});
|
|
expect(checkPilotEligibility({ "heavy-cargo": 1 }, heavyTier2).ok).toBe(false);
|
|
});
|
|
|
|
it("lets a pilot with Heavy Cargo 2 take it", () => {
|
|
expect(checkPilotEligibility({ "heavy-cargo": 2 }, heavyTier2)).toEqual({ ok: true });
|
|
});
|
|
|
|
it("stops a level-0 pilot from taking a route needing Long Haul 1", () => {
|
|
expect(checkPilotEligibility({}, longRoute)).toEqual({
|
|
ok: false,
|
|
reason: "long-haul-too-low",
|
|
});
|
|
expect(checkPilotEligibility({ "long-haul": 1 }, longRoute)).toEqual({ ok: true });
|
|
});
|
|
});
|