forked from conaticus/boolean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.test.ts
30 lines (24 loc) · 997 Bytes
/
utils.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { Collection, MessageAttachment } from "discord.js";
import { formatAttachmentsURL } from "../src/utils";
it("should format attachment url", () => {
const attachmentWithUrl = (url: string): MessageAttachment => {
const mockMessageAtatchment = new MessageAttachment(Buffer.alloc(0));
mockMessageAtatchment.url = url;
return mockMessageAtatchment;
};
const mockDataCollection = new Collection<string, MessageAttachment>();
mockDataCollection.set(
"1",
attachmentWithUrl("https://example.com/file.png")
);
expect(formatAttachmentsURL(mockDataCollection)).toBe(
"[`Attachment-0-File`](https://example.com/file.png)"
);
mockDataCollection.set(
"2",
attachmentWithUrl("https://example.com/file2.png")
);
expect(formatAttachmentsURL(mockDataCollection)).toBe(
"[`Attachment-0-File`](https://example.com/file.png)\n[`Attachment-1-File`](https://example.com/file2.png)"
);
});