43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildWalkingSkeletonVM } from "./walking-skeleton.vm.js";
|
|
|
|
describe("buildWalkingSkeletonVM", () => {
|
|
it("builds a ready VM with active content when the module is active", () => {
|
|
const vm = buildWalkingSkeletonVM({ tenantId: "t1", moduleKey: "walking-skeleton", connectorState: "active" });
|
|
|
|
expect(vm.status).toBe("ready");
|
|
expect(vm.data).toMatchObject({
|
|
tenantId: "t1",
|
|
moduleKey: "walking-skeleton",
|
|
connectorState: "active",
|
|
headlineKey: "walkingSkeleton.active.headline",
|
|
bodyKey: "walkingSkeleton.active.body",
|
|
});
|
|
expect(vm.data?.ctaKey).toBeUndefined();
|
|
});
|
|
|
|
it("builds a ready VM with locked content + upsell CTA when the module is locked", () => {
|
|
const vm = buildWalkingSkeletonVM({ tenantId: "t1", moduleKey: "walking-skeleton", connectorState: "locked" });
|
|
|
|
expect(vm.status).toBe("ready");
|
|
expect(vm.data?.connectorState).toBe("locked");
|
|
expect(vm.data?.headlineKey).toBe("walkingSkeleton.locked.headline");
|
|
expect(vm.data?.ctaKey).toBe("walkingSkeleton.locked.cta");
|
|
});
|
|
|
|
it("builds an empty VM when the module is hidden", () => {
|
|
const vm = buildWalkingSkeletonVM({ tenantId: "t1", moduleKey: "walking-skeleton", connectorState: "hidden" });
|
|
|
|
expect(vm.status).toBe("empty");
|
|
expect(vm.data).toBeUndefined();
|
|
});
|
|
|
|
it("uses only i18n keys, never raw display strings", () => {
|
|
const vm = buildWalkingSkeletonVM({ tenantId: "t1", moduleKey: "walking-skeleton", connectorState: "active" });
|
|
const keyPattern = /^[a-z][a-zA-Z0-9]*(?:\.[a-zA-Z0-9]+)+$/;
|
|
|
|
expect(vm.data?.headlineKey).toMatch(keyPattern);
|
|
expect(vm.data?.bodyKey).toMatch(keyPattern);
|
|
});
|
|
});
|