CLI: default pairing channel for pairing commands
This commit is contained in:
@@ -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:");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user