test: tighten tlon media send assertions

This commit is contained in:
Shakker
2026-05-10 17:19:01 +01:00
parent 46d9041646
commit d1886d6028
2 changed files with 29 additions and 21 deletions

View File

@@ -54,14 +54,14 @@ describe("tlon monitor media", () => {
const result = await downloadMedia("https://example.com/photo.png");
expect(fetchRemoteMediaMock).toHaveBeenCalledWith(
expect.objectContaining({
url: "https://example.com/photo.png",
maxBytes: MAX_IMAGE_BYTES,
readIdleTimeoutMs: 30_000,
requestInit: { method: "GET" },
}),
);
expect(fetchRemoteMediaMock).toHaveBeenCalledTimes(1);
expect(fetchRemoteMediaMock).toHaveBeenCalledWith({
url: "https://example.com/photo.png",
maxBytes: MAX_IMAGE_BYTES,
readIdleTimeoutMs: 30_000,
ssrfPolicy: undefined,
requestInit: { method: "GET" },
});
expect(saveMediaBufferMock).toHaveBeenCalledWith(
Buffer.from("image-data"),
"image/png",

View File

@@ -55,21 +55,29 @@ describe("sendDm", () => {
});
expect(scot).toHaveBeenCalledWith("ud", 1_700_000_000_000n);
expect(poke).toHaveBeenCalledWith(
expect.objectContaining({
json: expect.objectContaining({
channel: expect.objectContaining({
action: {
post: {
reply: expect.objectContaining({
id: "~2024.1.1",
}),
expect(poke).toHaveBeenCalledWith({
app: "channels",
mark: "channel-action-1",
json: {
channel: {
nest: "chat/~nec/general",
action: {
post: {
reply: {
id: "~2024.1.1",
action: {
add: {
content: [{ inline: ["threaded"] }],
author: "~zod",
sent: 1_700_000_000_000,
},
},
},
},
}),
}),
}),
);
},
},
},
});
expect(result.receipt.threadId).toBe("~nec/general");
});
});