





















@@ -1937,18 +1937,14 @@ describe("deliverOutboundPayloads", () => {
19371937});
1938193819391939expect(sendMatrix).toHaveBeenCalledTimes(2);
1940-expect(sendMatrix).toHaveBeenNthCalledWith(
1941-1,
1942-"!room:example",
1943-"Line one",
1944-expect.objectContaining({ cfg }),
1945-);
1946-expect(sendMatrix).toHaveBeenNthCalledWith(
1947-2,
1948-"!room:example",
1949-"Line two",
1950-expect.objectContaining({ cfg }),
1951-);
1940+const firstChunkCall = sendMatrix.mock.calls[0];
1941+expect(firstChunkCall?.[0]).toBe("!room:example");
1942+expect(firstChunkCall?.[1]).toBe("Line one");
1943+expect((firstChunkCall?.[2] as { cfg?: unknown } | undefined)?.cfg).toBe(cfg);
1944+const secondChunkCall = sendMatrix.mock.calls[1];
1945+expect(secondChunkCall?.[0]).toBe("!room:example");
1946+expect(secondChunkCall?.[1]).toBe("Line two");
1947+expect((secondChunkCall?.[2] as { cfg?: unknown } | undefined)?.cfg).toBe(cfg);
19521948});
1953194919541950it("lets explicit formatting options override configured chunking", async () => {
@@ -2137,14 +2133,13 @@ describe("deliverOutboundPayloads", () => {
21372133deps: { matrix: sendMatrix },
21382134});
213921352140-expect(sendMatrix).toHaveBeenCalledWith(
2141-"!room:example",
2142-"hello",
2143-expect.objectContaining({
2144- cfg,
2145-mediaUrl: "https://example.com/a.png",
2146-}),
2147-);
2136+const sendMatrixOptions = sendMatrix.mock.calls[0]?.[2] as
2137+| { cfg?: unknown; mediaUrl?: unknown }
2138+| undefined;
2139+expect(sendMatrix.mock.calls[0]?.[0]).toBe("!room:example");
2140+expect(sendMatrix.mock.calls[0]?.[1]).toBe("hello");
2141+expect(sendMatrixOptions?.cfg).toBe(cfg);
2142+expect(sendMatrixOptions?.mediaUrl).toBe("https://example.com/a.png");
21482143});
2149214421502145it("keeps markdown images as text for channels that do not opt in", async () => {
@@ -2158,11 +2153,12 @@ describe("deliverOutboundPayloads", () => {
21582153deps: { matrix: sendMatrix },
21592154});
216021552161-expect(sendMatrix).toHaveBeenCalledWith(
2162-"!room:example",
2156+const sendMatrixOptions = sendMatrix.mock.calls[0]?.[2] as { mediaUrl?: unknown } | undefined;
2157+expect(sendMatrix.mock.calls[0]?.[0]).toBe("!room:example");
2158+expect(sendMatrix.mock.calls[0]?.[1]).toBe(
21632159"Tech: ",
2164-expect.not.objectContaining({ mediaUrl: expect.any(String) }),
21652160);
2161+expect(sendMatrixOptions?.mediaUrl).toBeUndefined();
21662162});
2167216321682164it("extracts markdown images for channels that opt in", async () => {
@@ -2188,11 +2184,10 @@ describe("deliverOutboundPayloads", () => {
21882184deps: { matrix: sendMatrix },
21892185});
219021862191-expect(sendMatrix).toHaveBeenCalledWith(
2192-"!room:example",
2193-"Chart now",
2194-expect.objectContaining({ mediaUrl: "https://example.com/chart.png" }),
2195-);
2187+const sendMatrixOptions = sendMatrix.mock.calls[0]?.[2] as { mediaUrl?: unknown } | undefined;
2188+expect(sendMatrix.mock.calls[0]?.[0]).toBe("!room:example");
2189+expect(sendMatrix.mock.calls[0]?.[1]).toBe("Chart now");
2190+expect(sendMatrixOptions?.mediaUrl).toBe("https://example.com/chart.png");
21962191});
2197219221982193it("normalizes payloads and drops empty entries", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。