Skip to content

Commit

Permalink
test: Fix failing tests
Browse files Browse the repository at this point in the history
* Fix wrong type cast
* Fix erroneously provided `done` argument causing test to hang
  • Loading branch information
FoxxMD committed Apr 3, 2024
1 parent 1ba48cc commit b319ca7
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions tests/embed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Basic Message Building', function () {

const [messages, eventCount] = buildMessages(defaultTestDigest(), [event], images);
assert.isTrue(true, 'is true');
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});

Expand All @@ -59,7 +59,7 @@ describe('Basic Message Building', function () {

const [messages, eventCount] = buildMessages(defaultTestDigest(), [event], images);
assert.isTrue(true, 'is true');
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});
});
Expand All @@ -79,11 +79,11 @@ describe('Embed Collapsing', function () {

assert.exists((messages[0].embeds[0] as EmbedBuilder).data.image);
assert.notExists((messages[0].embeds[0] as EmbedBuilder).data.thumbnail);
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});

it('Collapses to poster', async function (done) {
it('Collapses to poster', async function () {
const rand = uniqueRandomNumber();
const events: TautulliRequestData[] = [];
const images: TautulliRequestFileData[] = [];
Expand All @@ -106,7 +106,7 @@ describe('Embed Collapsing', function () {
const [messages, eventCount] = buildMessages(digest, events, images);

assert.exists((messages[0].embeds[0] as EmbedBuilder).data.image);
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});

Expand All @@ -126,11 +126,11 @@ describe('Embed Collapsing', function () {

assert.exists((messages[0].embeds[0] as EmbedBuilder).data.thumbnail);
assert.notExists((messages[0].embeds[0] as EmbedBuilder).data.image);
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});

it('Collapses to text', async function (done) {
it('Collapses to text', async function () {
const rand = uniqueRandomNumber();
const events: TautulliRequestData[] = [];
const images: TautulliRequestFileData[] = [];
Expand All @@ -153,7 +153,7 @@ describe('Embed Collapsing', function () {

assert.notExists((messages[0].embeds[0] as EmbedBuilder).data.thumbnail);
assert.notExists((messages[0].embeds[0] as EmbedBuilder).data.image);
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});

Expand Down Expand Up @@ -182,7 +182,7 @@ describe('Embed Collapsing', function () {
assert.notExists((messages[0].embeds[0] as EmbedBuilder).data.thumbnail);
assert.notExists((messages[0].embeds[0] as EmbedBuilder).data.image);
assert.equal(messages[0].embeds.length, 1);
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});

Expand All @@ -198,7 +198,7 @@ describe('Embed Collapsing', function () {
}
}
const charCount = events.reduce((acc, curr) => {
return acc + (curr.content.embeds[0] as EmbedBuilder).data.title.length;
return acc + (curr.content.embeds[0] as APIEmbed).title.length;
}, 0);
const calculatedEmbedCount = Math.ceil(charCount / 900);

Expand All @@ -213,7 +213,7 @@ describe('Embed Collapsing', function () {
const [messages, eventCount] = buildMessages(digest, events, images);

assert.equal(messages[0].embeds.length, calculatedEmbedCount);
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});

Expand All @@ -234,7 +234,7 @@ describe('Embed Collapsing', function () {
assert.equal(messages[0].embeds.length, 10);
assert.notExists((messages[0].embeds[9] as APIEmbed).thumbnail);
assert.notExists((messages[0].embeds[9] as APIEmbed).image);
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});

Expand All @@ -256,7 +256,7 @@ describe('Embed Collapsing', function () {
assert.notExists((messages[0].embeds[9] as EmbedBuilder).data.thumbnail);
assert.notExists((messages[0].embeds[9] as EmbedBuilder).data.image);
assert.isTrue((messages[0].embeds[9] as EmbedBuilder).data.description.includes('and 21 more'));
sendMessages(defaultTestDigest(), messages);
await sendMessages(defaultTestDigest(), messages);
return;
});
});

0 comments on commit b319ca7

Please sign in to comment.