From 0383c79c9c16971149644b7f70adf7328eeebad3 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 19 Feb 2026 07:27:42 +0000 Subject: [PATCH] test(cli): dedupe account-option assertion in message helper tests --- src/cli/program/message/helpers.test.ts | 29 +++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/cli/program/message/helpers.test.ts b/src/cli/program/message/helpers.test.ts index 67b716cd35a..15bb60828b4 100644 --- a/src/cli/program/message/helpers.test.ts +++ b/src/cli/program/message/helpers.test.ts @@ -69,6 +69,17 @@ async function runSendAction(opts: Record = {}) { await expect(runMessageAction("send", { ...baseSendOptions, ...opts })).rejects.toThrow("exit"); } +function expectNoAccountFieldInPassedOptions() { + const passedOpts = ( + messageCommandMock.mock.calls as unknown as Array<[Record]> + )?.[0]?.[0]; + expect(passedOpts).toBeTruthy(); + if (!passedOpts) { + throw new Error("expected message command call"); + } + expect(passedOpts).not.toHaveProperty("account"); +} + describe("runMessageAction", () => { beforeEach(() => { vi.clearAllMocks(); @@ -180,14 +191,7 @@ describe("runMessageAction", () => { expect.anything(), ); // account key should be stripped in favor of accountId - const passedOpts = ( - messageCommandMock.mock.calls as unknown as Array<[Record]> - )?.[0]?.[0]; - expect(passedOpts).toBeTruthy(); - if (!passedOpts) { - throw new Error("expected message command call"); - } - expect(passedOpts).not.toHaveProperty("account"); + expectNoAccountFieldInPassedOptions(); }); it("strips non-string account values instead of passing accountId", async () => { @@ -212,13 +216,6 @@ describe("runMessageAction", () => { expect.anything(), expect.anything(), ); - const passedOpts = ( - messageCommandMock.mock.calls as unknown as Array<[Record]> - )?.[0]?.[0]; - expect(passedOpts).toBeTruthy(); - if (!passedOpts) { - throw new Error("expected message command call"); - } - expect(passedOpts).not.toHaveProperty("account"); + expectNoAccountFieldInPassedOptions(); }); });