


















@@ -153,7 +153,15 @@ async function waitForMessage(onMessage: ReturnType<typeof vi.fn>) {
153153interval: 1,
154154timeout: 250,
155155});
156-return onMessage.mock.calls.at(0)?.[0];
156+return onMessage.mock.calls[0]?.[0];
157+}
158+159+function latestSaveMediaBufferCall() {
160+const call = saveMediaBufferSpy.mock.calls[saveMediaBufferSpy.mock.calls.length - 1];
161+if (!call) {
162+throw new Error("expected saveMediaBuffer call");
163+}
164+return call;
157165}
158166159167function requireMediaPath(value: unknown): string {
@@ -239,8 +247,8 @@ describe("web inbound media saves with extension", () => {
239247const second = await waitForMessage(onMessage);
240248expect(second.mediaFileName).toBe(fileName);
241249expect(saveMediaBufferSpy).toHaveBeenCalled();
242-const lastCall = saveMediaBufferSpy.mock.calls.at(-1);
243-expect(lastCall?.[4]).toBe(fileName);
250+const lastCall = latestSaveMediaBufferCall();
251+expect(lastCall[4]).toBe(fileName);
244252245253await listener.close();
246254});
@@ -287,8 +295,8 @@ describe("web inbound media saves with extension", () => {
287295const mediaPath = requireMediaPath(inbound.mediaPath);
288296expect(path.extname(mediaPath)).toBe(".jpg");
289297expect(saveMediaBufferSpy).toHaveBeenCalled();
290-const lastCall = saveMediaBufferSpy.mock.calls.at(-1);
291-expect(lastCall?.[1]).toBe("image/jpeg");
298+const lastCall = latestSaveMediaBufferCall();
299+expect(lastCall[1]).toBe("image/jpeg");
292300293301await listener.close();
294302});
@@ -323,8 +331,8 @@ describe("web inbound media saves with extension", () => {
323331324332await waitForMessage(onMessage);
325333expect(saveMediaBufferSpy).toHaveBeenCalled();
326-const lastCall = saveMediaBufferSpy.mock.calls.at(-1);
327-expect(lastCall?.[3]).toBe(1 * 1024 * 1024);
334+const lastCall = latestSaveMediaBufferCall();
335+expect(lastCall[3]).toBe(1 * 1024 * 1024);
328336329337await listener.close();
330338});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。