import assert from "node:assert";
import { describe, it } from "node:test";
import { captureCliInvocationEvent, getCliInvocationProperties, } from "./cli-invocation.js";
describe("getCliInvocationProperties", () => {
    it("captures the top-level CLI command token", () => {
        assert.deepEqual(getCliInvocationProperties({ _: ["deploy"] }, "1.2.3"), {
            version: "1.2.3",
            cliCommand: "deploy",
        });
        assert.deepEqual(getCliInvocationProperties({ _: ["bucket"] }, "1.2.3"), {
            version: "1.2.3",
            cliCommand: "bucket",
        });
        assert.deepEqual(getCliInvocationProperties({ _: ["logout"] }, "1.2.3"), {
            version: "1.2.3",
            cliCommand: "logout",
        });
        assert.deepEqual(getCliInvocationProperties({ _: ["hello"] }, "1.2.3"), {
            version: "1.2.3",
            cliCommand: "hello",
        });
    });
    it("canonicalizes OpenAPI command aliases", () => {
        assert.deepEqual(getCliInvocationProperties({ _: ["oas"] }, "1.2.3"), {
            version: "1.2.3",
            cliCommand: "openapi",
        });
        assert.deepEqual(getCliInvocationProperties({ _: ["open-api"] }, "1.2.3"), {
            version: "1.2.3",
            cliCommand: "openapi",
        });
    });
    it("does not include positional values after the command token", () => {
        assert.deepEqual(getCliInvocationProperties({ _: ["deploy", "customer-project-name"] }, "1.2.3"), {
            version: "1.2.3",
            cliCommand: "deploy",
        });
    });
    it("reports unknown when no command token is present", () => {
        assert.deepEqual(getCliInvocationProperties({ _: [] }, "1.2.3"), {
            version: "1.2.3",
            cliCommand: "unknown",
        });
    });
    it("does not fail the CLI when analytics capture fails", async () => {
        await assert.doesNotReject(captureCliInvocationEvent({ _: ["deploy"] }, "1.2.3", async () => {
            throw new Error("analytics failed");
        }));
    });
});
//# sourceMappingURL=cli-invocation.test.js.map