Add more tests
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 25s

This commit is contained in:
Mylloon 2024-10-14 23:31:47 +02:00
parent 4ac6ec0a9d
commit c7fff7520b
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -60,6 +60,68 @@ describe("Attachements Handler", () => {
]), ]),
); );
expect(embedTest).toStrictEqual(embedExpected);
});
}
{
const name = "Two fields with multiples files each";
test(name, () => {
// 102 is the maximum for [f](url) before rupture
const max = 102;
const total = 150;
const embedExpected = new EmbedBuilder();
embedExpected.addFields(
{
name: "yes_s (1)",
value: Array.from({ length: max }, () => "[f](url)").join(", "),
},
{
name: "yes_s (2)",
value: Array.from({ length: total - max }, () => "[f](url)").join(", "),
},
);
const embedTest = new EmbedBuilder();
handleAttachments(
map,
embedTest,
new Collection(
Array.from({ length: total }, () => [newKey(), { name: "f", url: "url" } as Attachment]),
),
);
expect(embedTest).toStrictEqual(embedExpected);
});
}
{
const name = "Two fields with one field with one element";
test(name, () => {
// 102 is the maximum for [f](url) before rupture
const max = 102;
const total = 103;
const embedExpected = new EmbedBuilder();
embedExpected.addFields(
{
name: "yes_s (1)",
value: Array.from({ length: max }, () => "[f](url)").join(", "),
},
{
name: "no_s (2)",
value: Array.from({ length: total - max }, () => "[f](url)").join(", "),
},
);
const embedTest = new EmbedBuilder();
handleAttachments(
map,
embedTest,
new Collection(
Array.from({ length: total }, () => [newKey(), { name: "f", url: "url" } as Attachment]),
),
);
expect(embedTest).toStrictEqual(embedExpected); expect(embedTest).toStrictEqual(embedExpected);
}); });
} }