add vitest in project

This commit is contained in:
MapleLeaf
2022-01-09 22:15:47 -06:00
parent 661a253d8c
commit 017a417773
16 changed files with 165 additions and 1409 deletions

View File

@@ -1,4 +1,5 @@
import React from "react"
import { test } from "vitest"
import { ReacordTester } from "../library/core/reacord-tester"
import { ActionRow, Button, Select } from "../library/main"

View File

@@ -1,2 +1,3 @@
import { test } from "vitest"
test.todo("channel message renderer")
export {}

View File

@@ -1,2 +1,3 @@
import { test } from "vitest"
test.todo("discord js integration")
export {}

View File

@@ -1,4 +1,5 @@
import React from "react"
import { test } from "vitest"
import { ReacordTester } from "../library/core/reacord-tester"
import {
Embed,

View File

@@ -1,2 +1,2 @@
import { test } from "vitest"
test.todo("ephemeral reply")
export {}

View File

@@ -1,3 +1,4 @@
import { test } from "vitest"
test.todo("button onClick")
test.todo("select onChange")
export {}

View File

@@ -1,4 +1,5 @@
import React from "react"
import { test } from "vitest"
import { ReacordTester } from "../library/core/reacord-tester"
import { Link } from "../library/main"

View File

@@ -1,4 +1,5 @@
import * as React from "react"
import { test } from "vitest"
import {
Button,
Embed,

View File

@@ -1,6 +1,6 @@
import { test } from "vitest"
// test that the interaction update is _eventually_ deferred if there's no component update,
// and that update isn't called after the fact
// ...somehow
test.todo("defer update timeout")
export {}

View File

@@ -1,10 +1,10 @@
import { jest } from "@jest/globals"
import React, { useState } from "react"
import { expect, fn, test } from "vitest"
import { Button, Option, ReacordTester, Select } from "../library/main"
test("single select", async () => {
const tester = new ReacordTester()
const onSelect = jest.fn()
const onSelect = fn()
function TestSelect() {
const [value, setValue] = useState<string>()
@@ -74,7 +74,7 @@ test("single select", async () => {
test("multiple select", async () => {
const tester = new ReacordTester()
const onSelect = jest.fn()
const onSelect = fn()
function TestSelect() {
const [values, setValues] = useState<string[]>([])
@@ -125,13 +125,13 @@ test("multiple select", async () => {
expect(onSelect).toHaveBeenCalledTimes(0)
tester.findSelectByPlaceholder("select").select("1", "3")
await assertSelect(expect.arrayContaining(["1", "3"]))
await assertSelect(expect.arrayContaining(["1", "3"]) as unknown as string[])
expect(onSelect).toHaveBeenCalledWith(
expect.objectContaining({ values: expect.arrayContaining(["1", "3"]) }),
)
tester.findSelectByPlaceholder("select").select("2")
await assertSelect(expect.arrayContaining(["2"]))
await assertSelect(expect.arrayContaining(["2"]) as unknown as string[])
expect(onSelect).toHaveBeenCalledWith(
expect.objectContaining({ values: expect.arrayContaining(["2"]) }),
)