Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { assertI18nLabel, empty, ready, type ActionCallbacks, type SidebarRegistryItem, type VMState } from "./index.js";
|
||||
|
||||
describe("@toolctrl/view-models", () => {
|
||||
test("exports serializable VM state helpers", () => {
|
||||
expect(ready({ id: "1" })).toEqual({ status: "ready", data: { id: "1" } } satisfies VMState<{ id: string }>);
|
||||
expect(empty()).toEqual({ status: "empty" });
|
||||
});
|
||||
|
||||
test("keeps action callbacks generic and UI-free", async () => {
|
||||
const calls: string[] = [];
|
||||
const callbacks: ActionCallbacks<{ id: string }> = {
|
||||
onUpdate: async (item) => {
|
||||
calls.push(item.id);
|
||||
},
|
||||
};
|
||||
await callbacks.onUpdate?.({ id: "item_1" });
|
||||
expect(calls).toEqual(["item_1"]);
|
||||
});
|
||||
|
||||
test("requires i18n-key labels for shell registries", () => {
|
||||
const item: SidebarRegistryItem = { id: "home", href: "/", labelKey: "shell.nav.home", permission: "resource.view" };
|
||||
expect(assertI18nLabel(item)).toBe(item);
|
||||
expect(() => assertI18nLabel({ labelKey: "Home" })).toThrow(/i18n keys/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user