mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 19:31:37 +00:00
test(cli): dedupe account-option assertion in message helper tests
This commit is contained in:
@@ -69,6 +69,17 @@ async function runSendAction(opts: Record<string, unknown> = {}) {
|
|||||||
await expect(runMessageAction("send", { ...baseSendOptions, ...opts })).rejects.toThrow("exit");
|
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", () => {
|
describe("runMessageAction", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
@@ -180,14 +191,7 @@ describe("runMessageAction", () => {
|
|||||||
expect.anything(),
|
expect.anything(),
|
||||||
);
|
);
|
||||||
// account key should be stripped in favor of accountId
|
// account key should be stripped in favor of accountId
|
||||||
const passedOpts = (
|
expectNoAccountFieldInPassedOptions();
|
||||||
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");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("strips non-string account values instead of passing accountId", async () => {
|
it("strips non-string account values instead of passing accountId", async () => {
|
||||||
@@ -212,13 +216,6 @@ describe("runMessageAction", () => {
|
|||||||
expect.anything(),
|
expect.anything(),
|
||||||
expect.anything(),
|
expect.anything(),
|
||||||
);
|
);
|
||||||
const passedOpts = (
|
expectNoAccountFieldInPassedOptions();
|
||||||
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");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user