























@@ -69,12 +69,9 @@ async function primeInboundReplyHandle(params: {
6969);
7070await waitForMessageCalls(params.onMessage, 1);
717172-const inbound = params.onMessage.mock.calls.at(0)?.at(0) as
73-| {
74-reply: (text: string) => Promise<void>;
75-}
76-| undefined;
77-expect(inbound).toBeDefined();
72+const inbound = inboundMessage(params.onMessage) as {
73+reply: (text: string) => Promise<void>;
74+};
78757976return { listener, sock, inbound };
8077}
@@ -267,7 +264,7 @@ describe("web monitor inbox", () => {
267264expect(inbound.groupSubject).toBe("Recovered Group");
268265expect(inbound.senderE164).toBe("+444");
269266expect(inbound.chatType).toBe("group");
270-expect(onMessage.mock.calls.at(0)?.[0].groupParticipants).toBeUndefined();
267+expect(inbound.groupParticipants).toBeUndefined();
271268272269await second.listener.close();
273270});
@@ -348,14 +345,11 @@ describe("web monitor inbox", () => {
348345);
349346await waitForMessageCalls(onMessage, 1);
350347351-const inbound = onMessage.mock.calls.at(0)?.at(0) as
352-| {
353-reply: (text: string) => Promise<void>;
354-sendMedia: (payload: Record<string, unknown>) => Promise<void>;
355-sendComposing: () => Promise<void>;
356-}
357-| undefined;
358-expect(inbound).toBeDefined();
348+const inbound = inboundMessage(onMessage) as {
349+reply: (text: string) => Promise<void>;
350+sendMedia: (payload: Record<string, unknown>) => Promise<void>;
351+sendComposing: () => Promise<void>;
352+};
359353360354const replacementSock = {
361355sendMessage: vi.fn(async () => undefined),
@@ -365,9 +359,9 @@ describe("web monitor inbox", () => {
365359InboxMonitorOptions["socketRef"]
366360>["current"];
367361368-await inbound?.reply("pong");
369-await inbound?.sendMedia({ text: "after-reconnect" });
370-await inbound?.sendComposing();
362+await inbound.reply("pong");
363+await inbound.sendMedia({ text: "after-reconnect" });
364+await inbound.sendComposing();
371365372366expect(replacementSock.sendMessage).toHaveBeenNthCalledWith(1, "999@s.whatsapp.net", {
373367text: "pong",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。