mirror of
https://github.com/cupcakearmy/formhero.git
synced 2024-12-22 08:06:24 +00:00
24 lines
663 B
TypeScript
24 lines
663 B
TypeScript
import { fireEvent, screen } from '@testing-library/react'
|
|
import React from 'react'
|
|
import { expect } from 'vitest'
|
|
|
|
export const Insight = {
|
|
Portal({ data }: { data: any }) {
|
|
return <div data-testid="result">{JSON.stringify(data)}</div>
|
|
},
|
|
async verify(obj: any) {
|
|
const result = await screen.findByTestId('result')
|
|
const data = JSON.parse(result.innerText)
|
|
expect(data).toMatchObject(obj)
|
|
},
|
|
}
|
|
|
|
export const Util = {
|
|
find<E extends HTMLElement = HTMLInputElement>(id: string) {
|
|
return screen.findByTestId<E>(id)
|
|
},
|
|
writeToField(node: HTMLInputElement, value: string) {
|
|
fireEvent.change(node, { target: { value } })
|
|
},
|
|
}
|