Add a test, speed up large tests
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 18s
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 18s
This commit is contained in:
parent
c7fff7520b
commit
23f8d5d4d1
1 changed files with 27 additions and 6 deletions
|
@ -12,6 +12,9 @@ describe("Attachements Handler", () => {
|
|||
["e_attachements", "yes_s"],
|
||||
["e_attachement", "no_s"],
|
||||
]);
|
||||
// 102 is the maximum for [f](url) before rupture in a field
|
||||
const max = 102;
|
||||
const max_field = Array.from({ length: max }, () => "[f](url)").join(", ");
|
||||
{
|
||||
const name = "One image";
|
||||
test(name, () => {
|
||||
|
@ -28,6 +31,28 @@ describe("Attachements Handler", () => {
|
|||
expect(embedTest).toStrictEqual(embedExpected);
|
||||
});
|
||||
}
|
||||
{
|
||||
const name = "Two images";
|
||||
test(name, () => {
|
||||
const embedExpected = new EmbedBuilder();
|
||||
embedExpected.addFields({
|
||||
name: "yes_s",
|
||||
value: "[image.png](http://url), [image.png](http://url)",
|
||||
});
|
||||
|
||||
const embedTest = new EmbedBuilder();
|
||||
handleAttachments(
|
||||
map,
|
||||
embedTest,
|
||||
new Collection([
|
||||
[newKey(), { name: "image.png", url: "http://url" } as Attachment],
|
||||
[newKey(), { name: "image.png", url: "http://url" } as Attachment],
|
||||
]),
|
||||
);
|
||||
|
||||
expect(embedTest).toStrictEqual(embedExpected);
|
||||
});
|
||||
}
|
||||
{
|
||||
const name = "One link";
|
||||
test(name, () => {
|
||||
|
@ -66,15 +91,13 @@ describe("Attachements Handler", () => {
|
|||
{
|
||||
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(", "),
|
||||
value: max_field,
|
||||
},
|
||||
{
|
||||
name: "yes_s (2)",
|
||||
|
@ -97,15 +120,13 @@ describe("Attachements Handler", () => {
|
|||
{
|
||||
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(", "),
|
||||
value: max_field,
|
||||
},
|
||||
{
|
||||
name: "no_s (2)",
|
||||
|
|
Loading…
Reference in a new issue