diff --git a/tests/field.test.tsx b/tests/field.test.tsx index 20b6b2c4..f296bf15 100644 --- a/tests/field.test.tsx +++ b/tests/field.test.tsx @@ -2,6 +2,7 @@ import React from 'react'; import Form, { Field } from '../src'; import type { FormInstance } from '../src'; import { act, fireEvent, render } from '@testing-library/react'; +import { Input } from './common/InfoField'; import timeout from './common/timeout'; describe('Form.Field', () => { @@ -39,6 +40,50 @@ describe('Form.Field', () => { expect(formRef.getFieldsValue()).toEqual({ light: 'bamboo' }); }); + it('render props should receive initialValue on first render', () => { + let firstValue: any; + + render( +
, + ); + + expect(firstValue).toBe('bamboo'); + }); + + it('unmount should use latest onMetaChange', () => { + const onMetaChange1 = jest.fn(); + const onMetaChange2 = jest.fn(); + + const Demo: React.FC<{ onMetaChange: (meta: any) => void }> = props => { + const { onMetaChange } = props; + return ( + + ); + }; + + const { rerender, unmount } = render(