From e926fa39f6a5f284f874d958508c1bf412bab4c8 Mon Sep 17 00:00:00 2001 From: Kastriot Salihu Date: Fri, 29 May 2026 15:02:05 +0200 Subject: [PATCH] SP-758: add register() smoke test for asset-registry module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors the register() smoke-test pattern introduced for configuration-management in #363. Calling `module.register(testContext, mockConfigurator)` exercises every `.command().option().action()` line in asset-registry/module.ts, flipping the entire register() body to covered without spinning up Commander. Asserts: - All expected command groups are registered ("asset-registry", "skills", and the five leaf names) without throwing. - Each of the 6 leaf subcommands wires an action handler — the count guards against accidental additions / removals. Includes-AI-Code: true Co-authored-by: Cursor --- .../asset-registry-module.spec.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/commands/asset-registry/asset-registry-module.spec.ts b/tests/commands/asset-registry/asset-registry-module.spec.ts index a574fa7..17bde19 100644 --- a/tests/commands/asset-registry/asset-registry-module.spec.ts +++ b/tests/commands/asset-registry/asset-registry-module.spec.ts @@ -2,6 +2,7 @@ import Module = require("../../../src/commands/asset-registry/module"); import { Command, OptionValues } from "commander"; import { AssetRegistryService } from "../../../src/commands/asset-registry/asset-registry.service"; import { testContext } from "../../utls/test-context"; +import { createMockConfigurator } from "../../utls/configurator-mock"; jest.mock("../../../src/commands/asset-registry/asset-registry.service"); @@ -115,4 +116,34 @@ describe("Asset Registry Module", () => { await (module as any).getType(testContext, mockCommand, options); expect(mockService.getType).toHaveBeenCalledWith("BOARD_V2", false); }); + + describe("register", () => { + it("registers all expected command groups without throwing", () => { + const mockConfigurator = createMockConfigurator(); + + expect(() => new Module().register(testContext, mockConfigurator)).not.toThrow(); + + expect(mockConfigurator.command).toHaveBeenCalledWith("asset-registry"); + expect(mockConfigurator.command).toHaveBeenCalledWith("skills"); + expect(mockConfigurator.command).toHaveBeenCalledWith("list"); + expect(mockConfigurator.command).toHaveBeenCalledWith("get"); + expect(mockConfigurator.command).toHaveBeenCalledWith("schema"); + expect(mockConfigurator.command).toHaveBeenCalledWith("examples"); + expect(mockConfigurator.command).toHaveBeenCalledWith("validate"); + }); + + it("wires an action handler for every leaf subcommand", () => { + const mockConfigurator = createMockConfigurator(); + + new Module().register(testContext, mockConfigurator); + + // Each leaf command terminates the fluent chain with .action(handler). + // Keep this count in sync when adding or removing commands in module.ts. + const expectedLeafCommands = 6; + expect(mockConfigurator.action).toHaveBeenCalledTimes(expectedLeafCommands); + for (const call of mockConfigurator.action.mock.calls) { + expect(typeof call[0]).toBe("function"); + } + }); + }); });