Add more tests
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 25s
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 25s
This commit is contained in:
parent
4ac6ec0a9d
commit
c7fff7520b
1 changed files with 62 additions and 0 deletions
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue