Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

formOptions.test.ts

25 lines596 Bytes

1import { describe, expect, it } from 'vitest'
2import { FormApi, formOptions } from '../src/index'
3​
4describe('formOptions', () => {
5 it('should allow default values to be set', async () => {
6 type Person = {
7 firstName: string
8 lastName: string
9 }
10​
11 const formOpts = formOptions<Person>({
12 defaultValues: {
13 firstName: 'FirstName',
14 lastName: 'LastName',
15 },
16 })
17​
18 const form = new FormApi({
19 ...formOpts,
20 })
21​
22 expect(form.state.values['firstName']).toBe('FirstName')
23 expect(form.state.values['lastName']).toBe('LastName')
24 })
25})