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:
Corbin Crutchley
2023-08-28 07:33:44 -07:00
committed by GitHub
parent 25237e40d4
commit 7ee5524693
11 changed files with 2895 additions and 2182 deletions

View File

@@ -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 () => {