feat (cli): add account selector for pairing commands

This commit is contained in:
Vignesh Natarajan
2026-02-15 19:09:14 -08:00
parent 6957354d48
commit 6cf7c02d4a
2 changed files with 60 additions and 5 deletions

View File

@@ -94,6 +94,20 @@ describe("pairing cli", () => {
expect(listChannelPairingRequests).toHaveBeenCalledWith("telegram");
});
it("forwards --account for list", async () => {
const { registerPairingCli } = await import("./pairing-cli.js");
listChannelPairingRequests.mockResolvedValueOnce([]);
const program = new Command();
program.name("test");
registerPairingCli(program);
await program.parseAsync(["pairing", "list", "--channel", "telegram", "--account", "yy"], {
from: "user",
});
expect(listChannelPairingRequests).toHaveBeenCalledWith("telegram", process.env, "yy");
});
it("normalizes channel aliases", async () => {
const { registerPairingCli } = await import("./pairing-cli.js");
listChannelPairingRequests.mockResolvedValueOnce([]);
@@ -170,4 +184,33 @@ describe("pairing cli", () => {
});
expect(log).toHaveBeenCalledWith(expect.stringContaining("Approved"));
});
it("forwards --account for approve", async () => {
const { registerPairingCli } = await import("./pairing-cli.js");
approveChannelPairingCode.mockResolvedValueOnce({
id: "123",
entry: {
id: "123",
code: "ABCDEFGH",
createdAt: "2026-01-08T00:00:00Z",
lastSeenAt: "2026-01-08T00:00:00Z",
},
});
const program = new Command();
program.name("test");
registerPairingCli(program);
await program.parseAsync(
["pairing", "approve", "--channel", "telegram", "--account", "yy", "ABCDEFGH"],
{
from: "user",
},
);
expect(approveChannelPairingCode).toHaveBeenCalledWith({
channel: "telegram",
code: "ABCDEFGH",
accountId: "yy",
});
});
});