mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-27 03:17:48 +00:00
test: dedupe gateway push mock reads
This commit is contained in:
@@ -111,12 +111,16 @@ function expectInvalidRequestResponse(
|
||||
respond: ReturnType<typeof vi.fn>,
|
||||
expectedMessagePart: string,
|
||||
) {
|
||||
const call = respond.mock.calls.at(0) as RespondCall | undefined;
|
||||
const call = firstRespondCall(respond);
|
||||
expect(call?.[0]).toBe(false);
|
||||
expect(call?.[2]?.code).toBe(ErrorCodes.INVALID_REQUEST);
|
||||
expect(call?.[2]?.message).toContain(expectedMessagePart);
|
||||
}
|
||||
|
||||
function firstRespondCall(respond: ReturnType<typeof vi.fn>): RespondCall | undefined {
|
||||
return respond.mock.calls[0] as RespondCall | undefined;
|
||||
}
|
||||
|
||||
describe("push.test handler", () => {
|
||||
beforeEach(() => {
|
||||
mocks.getRuntimeConfig.mockClear();
|
||||
@@ -157,7 +161,7 @@ describe("push.test handler", () => {
|
||||
await invoke();
|
||||
|
||||
expect(sendApnsAlert).toHaveBeenCalledTimes(1);
|
||||
const call = respond.mock.calls.at(0) as RespondCall | undefined;
|
||||
const call = firstRespondCall(respond);
|
||||
expect(call?.[0]).toBe(true);
|
||||
const result = call?.[1] as ApnsPushResult | undefined;
|
||||
expect(result?.ok).toBe(true);
|
||||
@@ -216,7 +220,7 @@ describe("push.test handler", () => {
|
||||
},
|
||||
});
|
||||
expect(sendApnsAlert).toHaveBeenCalledTimes(1);
|
||||
const call = respond.mock.calls.at(0) as RespondCall | undefined;
|
||||
const call = firstRespondCall(respond);
|
||||
expect(call?.[0]).toBe(true);
|
||||
const result = call?.[1] as ApnsPushResult | undefined;
|
||||
expect(result?.ok).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user