test: dedupe gateway push mock reads

This commit is contained in:
Peter Steinberger
2026-05-12 22:33:51 +01:00
parent 041906e2d5
commit ae9b7041ef

View File

@@ -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);