34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { companionSpecReadinessFromCache } from "./companionSpecReadiness";
|
|
|
|
describe("companion readiness offline cache", () => {
|
|
it("falls back to shipped defaults when the cached policy is corrupt", () => {
|
|
const cached = companionSpecReadinessFromCache("{not-json");
|
|
expect(cached.revision).toBe(0);
|
|
expect(cached.config.statuses["warrior:protection"]).toBe("ready");
|
|
expect(Object.values(cached.config.statuses).filter((status) => status === "ready")).toHaveLength(5);
|
|
});
|
|
|
|
it("retains the last valid published policy for offline play", () => {
|
|
const cached = companionSpecReadinessFromCache(JSON.stringify({
|
|
revision: 4,
|
|
updatedAt: 123,
|
|
updatedBy: "Phenom",
|
|
config: {
|
|
schemaVersion: 1,
|
|
statuses: {
|
|
"warrior:protection": "ready",
|
|
"priest:discipline": "ready",
|
|
"hunter:marksmanship": "ready",
|
|
"mage:fire": "ready",
|
|
"rogue:assassination": "ready",
|
|
"paladin:retribution": "beta",
|
|
},
|
|
},
|
|
}));
|
|
expect(cached.revision).toBe(4);
|
|
expect(cached.config.statuses["paladin:retribution"]).toBe("beta");
|
|
expect(cached.config.statuses["druid:balance"]).toBe("needs-testing");
|
|
});
|
|
});
|