Files
vitareba/lib/config/programmes.test.ts
g-butandClaude Sonnet 4.6 e704dfe474 test(config): add integrity tests for programmes and routes SSOT
- programmes.test.ts: verifies PROGRAMME_CONFIG + PHASE_CONFIG cover all enum
  values, have required fields, and exactly one featured programme
- routes.test.ts: verifies AUTH/PORTAL/ADMIN_ROUTES have correct prefixes,
  no duplicates, and no cross-group collisions

Tests: 221 → 239

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-23 22:26:48 +02:00

80 lines
2.7 KiB
TypeScript

import { describe, it, expect } from "vitest";
import {
PROGRAMME_ENUM_VALUES,
PHASE_ENUM_VALUES,
PROGRAMME_CONFIG,
PHASE_CONFIG,
type ProgrammeKey,
type PhaseKey,
} from "./programmes";
describe("PROGRAMME_CONFIG integrity", () => {
it("has an entry for every PROGRAMME_ENUM_VALUES item", () => {
for (const key of PROGRAMME_ENUM_VALUES) {
expect(PROGRAMME_CONFIG).toHaveProperty(key);
}
});
it("has no extra entries beyond PROGRAMME_ENUM_VALUES", () => {
const configKeys = Object.keys(PROGRAMME_CONFIG) as ProgrammeKey[];
for (const key of configKeys) {
expect(PROGRAMME_ENUM_VALUES).toContain(key);
}
expect(configKeys.length).toBe(PROGRAMME_ENUM_VALUES.length);
});
it("every entry has all required fields", () => {
for (const key of PROGRAMME_ENUM_VALUES) {
const entry = PROGRAMME_CONFIG[key];
expect(typeof entry.label).toBe("string");
expect(entry.label.length).toBeGreaterThan(0);
expect(typeof entry.description).toBe("string");
expect(entry.description.length).toBeGreaterThan(0);
expect(typeof entry.duration).toBe("string");
expect(typeof entry.price).toBe("string");
expect(typeof entry.featured).toBe("boolean");
expect(["primary", "outline"]).toContain(entry.btnStyle);
}
});
it("exactly one programme is featured", () => {
const featured = PROGRAMME_ENUM_VALUES.filter((k) => PROGRAMME_CONFIG[k].featured);
expect(featured.length).toBe(1);
});
});
describe("PHASE_CONFIG integrity", () => {
it("has an entry for every PHASE_ENUM_VALUES item", () => {
for (const key of PHASE_ENUM_VALUES) {
expect(PHASE_CONFIG).toHaveProperty(key);
}
});
it("has no extra entries beyond PHASE_ENUM_VALUES", () => {
const configKeys = Object.keys(PHASE_CONFIG) as PhaseKey[];
for (const key of configKeys) {
expect(PHASE_ENUM_VALUES).toContain(key);
}
expect(configKeys.length).toBe(PHASE_ENUM_VALUES.length);
});
it("every entry has label and description", () => {
for (const key of PHASE_ENUM_VALUES) {
const entry = PHASE_CONFIG[key];
expect(typeof entry.label).toBe("string");
expect(entry.label.length).toBeGreaterThan(0);
expect(typeof entry.description).toBe("string");
expect(entry.description.length).toBeGreaterThan(0);
}
});
it("covers all 6 lifecycle phases", () => {
expect(PHASE_ENUM_VALUES).toContain("intake");
expect(PHASE_ENUM_VALUES).toContain("assessment");
expect(PHASE_ENUM_VALUES).toContain("planning");
expect(PHASE_ENUM_VALUES).toContain("active");
expect(PHASE_ENUM_VALUES).toContain("review");
expect(PHASE_ENUM_VALUES).toContain("completed");
});
});