CLI: default pairing channel for pairing commands

This commit is contained in:
Vignesh Natarajan
2026-02-20 19:59:54 -08:00
parent be756b9a89
commit c0d5fc8d1e
3 changed files with 41 additions and 4 deletions

View File

@@ -163,6 +163,15 @@ describe("pairing cli", () => {
expect(listChannelPairingRequests).toHaveBeenCalledWith("zalo");
});
it("defaults list to the sole available channel", async () => {
listPairingChannels.mockReturnValueOnce(["slack"]);
listChannelPairingRequests.mockResolvedValueOnce([]);
await runPairing(["pairing", "list"]);
expect(listChannelPairingRequests).toHaveBeenCalledWith("slack");
});
it("accepts channel as positional for approve (npm-run compatible)", async () => {
mockApprovedPairing();
@@ -199,4 +208,20 @@ describe("pairing cli", () => {
accountId: "yy",
});
});
it("defaults approve to the sole available channel when only code is provided", async () => {
listPairingChannels.mockReturnValueOnce(["slack"]);
mockApprovedPairing();
await runPairing(["pairing", "approve", "ABCDEFGH"]);
expect(approveChannelPairingCode).toHaveBeenCalledWith({
channel: "slack",
code: "ABCDEFGH",
});
});
it("keeps approve usage error when multiple channels exist and channel is omitted", async () => {
await expect(runPairing(["pairing", "approve", "ABCDEFGH"])).rejects.toThrow("Usage:");
});
});