add link component

This commit is contained in:
MapleLeaf
2021-12-26 14:38:18 -06:00
parent ad482d84f8
commit 7efc7d53c9
5 changed files with 102 additions and 2 deletions

49
test/link.test.tsx Normal file
View File

@@ -0,0 +1,49 @@
import React from "react"
import {
Link,
Reacord,
TestAdapter,
TestCommandInteraction,
} from "../library/main"
import { assertMessages } from "./assert-messages"
const adapter = new TestAdapter()
const reacord = new Reacord({ adapter })
const reply = reacord.createCommandReply(new TestCommandInteraction(adapter))
test("link", async () => {
reply.render(
<>
<Link url="https://example.com/">link text</Link>
<Link label="link text" url="https://example.com/" />
<Link label="link text" url="https://example.com/" disabled />
</>,
)
await assertMessages(adapter, [
{
content: "",
embeds: [],
actionRows: [
[
{
type: "link",
url: "https://example.com/",
label: "link text",
},
{
type: "link",
url: "https://example.com/",
label: "link text",
},
{
type: "link",
url: "https://example.com/",
label: "link text",
disabled: true,
},
],
],
},
])
})