test(cli): dedupe account-option assertion in message helper tests

This commit is contained in:
Peter Steinberger
2026-02-19 07:27:42 +00:00
parent 9ac6f46735
commit 0383c79c9c

View File

@@ -69,6 +69,17 @@ async function runSendAction(opts: Record<string, unknown> = {}) {
await expect(runMessageAction("send", { ...baseSendOptions, ...opts })).rejects.toThrow("exit");
}
function expectNoAccountFieldInPassedOptions() {
const passedOpts = (
messageCommandMock.mock.calls as unknown as Array<[Record<string, unknown>]>
)?.[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<string, unknown>]>
)?.[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<string, unknown>]>
)?.[0]?.[0];
expect(passedOpts).toBeTruthy();
if (!passedOpts) {
throw new Error("expected message command call");
}
expect(passedOpts).not.toHaveProperty("account");
expectNoAccountFieldInPassedOptions();
});
});