more test fixes

This commit is contained in:
itsMapleLeaf
2022-08-06 10:22:12 -05:00
parent e1f5eda3c7
commit 6084ab23e0
3 changed files with 81 additions and 61 deletions

View File

@@ -1,40 +1,48 @@
import { test } from "vitest"
// import { ReacordTester } from "./test-adapter"
import { ButtonStyle, ComponentType } from "discord.js"
import React from "react"
import { beforeEach, expect, test } from "vitest"
import { Link } from "../library/main"
import { ReacordTester } from "./tester"
// const tester = new ReacordTester()
test.skip("link", async () => {
// await tester.assertRender(
// <>
// <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 />
// </>,
// [
// {
// 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,
// },
// ],
// ],
// },
// ],
// )
let tester: ReacordTester
beforeEach(async () => {
tester = await ReacordTester.create()
})
test("link", async () => {
const { message } = await tester.render(
"link",
<>
<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 />
</>,
)
expect(message.components.map((c) => c.toJSON())).toEqual([
{
type: ComponentType.ActionRow,
components: [
{
type: ComponentType.Button,
style: ButtonStyle.Link,
url: "https://example.com/",
label: "link text",
},
{
type: ComponentType.Button,
style: ButtonStyle.Link,
url: "https://example.com/",
label: "link text",
},
{
type: ComponentType.Button,
style: ButtonStyle.Link,
url: "https://example.com/",
label: "link text",
disabled: true,
},
],
},
])
})