30 lines
905 B
TypeScript
30 lines
905 B
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import {
|
|
anyCapability,
|
|
type HousekeepingWidgetDefinition,
|
|
ok,
|
|
} from "../../foundation/contracts";
|
|
import { toOperationsWidgetOptions } from "./personalization-model";
|
|
|
|
describe("toOperationsWidgetOptions", () => {
|
|
it("projects provider definitions to a serializable client view model", () => {
|
|
const load = vi.fn(async () => ok({ count: 1 }, "widget"));
|
|
const definitions: readonly HousekeepingWidgetDefinition[] = [
|
|
{
|
|
id: "people.queue",
|
|
owner: "people",
|
|
capability: anyCapability("admin.users.view"),
|
|
kind: "mandatory",
|
|
load,
|
|
},
|
|
];
|
|
|
|
const options = toOperationsWidgetOptions(definitions);
|
|
|
|
expect(options).toEqual([{ id: "people.queue", kind: "mandatory" }]);
|
|
expect(structuredClone(options)).toEqual(options);
|
|
expect(options[0]).not.toHaveProperty("load");
|
|
expect(load).not.toHaveBeenCalled();
|
|
});
|
|
});
|