refactor and simplify things

This commit is contained in:
MapleLeaf
2021-12-22 10:35:55 -06:00
parent 7b3ce42138
commit 765c6fadbb
26 changed files with 351 additions and 441 deletions

View File

@@ -74,14 +74,7 @@ test("empty embed fallback", async () => {
test("embed with only author", async () => {
await root.render(<Embed author={{ name: "only author" }} />)
await assertMessages([
{ embeds: [{ description: "_ _", author: { name: "only author" } }] },
])
})
test("empty embed author", async () => {
await root.render(<Embed author={{}} />)
await assertMessages([{ embeds: [{ description: "_ _" }] }])
await assertMessages([{ embeds: [{ author: { name: "only author" } }] }])
})
test("kitchen sink", async () => {
@@ -252,7 +245,7 @@ async function assertMessages(expected: MessageOptions[]) {
}
function extractMessageData(message: Message): MessageOptions {
return {
return pruneUndefinedValues({
content: nonEmptyOrUndefined(message.content),
embeds: nonEmptyOrUndefined(
pruneUndefinedValues(
@@ -305,7 +298,7 @@ function extractMessageData(message: Message): MessageOptions {
}),
})),
),
}
})
}
function pruneUndefinedValues<T>(input: T) {