reply instance deletion

This commit is contained in:
MapleLeaf
2021-12-27 13:50:56 -06:00
parent 32c1e02f92
commit 8db2a16305
7 changed files with 75 additions and 17 deletions

View File

@@ -3,9 +3,9 @@ import { Button, Embed, EmbedField, EmbedTitle } from "../library/main"
import { TestCommandInteraction } from "../library/testing"
import { setupReacordTesting } from "./setup-testing"
const { reacord, adapter, assertMessages } = setupReacordTesting()
test("rendering behavior", async () => {
const { reacord, adapter, assertMessages } = setupReacordTesting()
const reply = reacord.createCommandReply(new TestCommandInteraction(adapter))
reply.render(<KitchenSinkCounter onDeactivate={() => reply.deactivate()} />)
@@ -241,6 +241,32 @@ test("rendering behavior", async () => {
])
})
test("delete", async () => {
const { reacord, adapter, assertMessages } = setupReacordTesting()
const reply = reacord.createCommandReply(new TestCommandInteraction(adapter))
reply.render(
<>
some text
<Embed>some embed</Embed>
<Button label="some button" onClick={() => {}} />
</>,
)
await assertMessages([
{
content: "some text",
embeds: [{ description: "some embed" }],
actionRows: [
[{ type: "button", style: "secondary", label: "some button" }],
],
},
])
reply.destroy()
await assertMessages([])
})
// test multiple instances that can be updated independently,
// + old instances getting deactivated once the limit is reached
test.todo("multiple instances")