20 lines
664 B
TypeScript
20 lines
664 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { addCommand } from "./index.js";
|
|
|
|
async function resolveValue<T>(value: T | (() => T) | (() => Promise<T>)): Promise<T> {
|
|
if (typeof value === "function") {
|
|
return await (value as () => T | Promise<T>)();
|
|
}
|
|
return value;
|
|
}
|
|
|
|
describe("add command tree", () => {
|
|
it("exposes hook / event-type / permission subcommands", async () => {
|
|
const meta = await resolveValue(addCommand.meta);
|
|
expect(meta).toMatchObject({ name: "add" });
|
|
|
|
const subs = await resolveValue(addCommand.subCommands);
|
|
expect(Object.keys(subs ?? {}).sort()).toEqual(["event-type", "hook", "permission"]);
|
|
});
|
|
});
|