mirror of
https://github.com/LukeHagar/form.git
synced 2025-12-10 12:27:45 +00:00
fix: Initial FieldAPI tests, made FieldAPI typings much more strict (#405)
* fix: initial work at fixing the typescript typings for fieldapi to be more strict * chore(form-core): change implementation of strict tdata * fix(form-core): insertValue should now be typed properly * test(form-core): validate array helpers * fix(form-core): make types for getSubField more narrow * chore: autoformat with prettier * chore: fix tests, eslint * chore: upgrade eslint deps * chore: upgrade nx and concurrent * chore: remove svelte from prettier plugins * chore: upgrade TypeScript version to avoid a TS codegen bug * chore: remove React 17 CI script temporarily * chore: fix build and formatter
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { fireEvent, render } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import '@testing-library/jest-dom'
|
||||
import * as React from 'react'
|
||||
import { createFormFactory } from '..'
|
||||
@@ -22,9 +22,11 @@ describe('useForm', () => {
|
||||
<form.Provider>
|
||||
<form.Field
|
||||
name="firstName"
|
||||
defaultValue={""}
|
||||
defaultValue={''}
|
||||
children={(field) => {
|
||||
return <input data-testid="fieldinput" {...field.getInputProps()} />
|
||||
return (
|
||||
<input data-testid="fieldinput" {...field.getInputProps()} />
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</form.Provider>
|
||||
@@ -32,10 +34,10 @@ describe('useForm', () => {
|
||||
}
|
||||
|
||||
const { getByTestId, queryByText } = render(<Comp />)
|
||||
const input = getByTestId("fieldinput");
|
||||
const input = getByTestId('fieldinput')
|
||||
expect(queryByText('FirstName')).not.toBeInTheDocument()
|
||||
await user.type(input, "FirstName")
|
||||
expect(input).toHaveValue("FirstName")
|
||||
await user.type(input, 'FirstName')
|
||||
expect(input).toHaveValue('FirstName')
|
||||
})
|
||||
|
||||
it('should allow default values to be set', async () => {
|
||||
|
||||
Reference in New Issue
Block a user