diff --git a/src/Field.tsx b/src/Field.tsx index 60d72a2c..6b356ccb 100644 --- a/src/Field.tsx +++ b/src/Field.tsx @@ -253,7 +253,7 @@ class Field extends React.Component implements F // Clean up state this.touched = false; this.dirty = false; - this.validatePromise = null; + this.validatePromise = undefined; this.errors = EMPTY_ERRORS; this.warnings = EMPTY_ERRORS; this.triggerMetaEvent(); diff --git a/tests/validate.test.tsx b/tests/validate.test.tsx index f97f5be1..ef4a5e40 100644 --- a/tests/validate.test.tsx +++ b/tests/validate.test.tsx @@ -797,14 +797,28 @@ describe('Form.Validate', () => { it('should trigger onFieldsChange 3 times', async () => { const onFieldsChange = jest.fn(); + const onMetaChange = jest.fn(); - const wrapper = mount( -
- - - -
, - ); + const App = () => { + const ref = React.useRef(null); + return ( +
+ { + onMetaChange(meta.validated); + }} + > + + + +
+ ); + }; + const wrapper = mount(); await changeValue(getField(wrapper, 'test'), ''); @@ -847,5 +861,10 @@ describe('Form.Validate', () => { ], expect.anything(), ); + // should reset validated and validating when reset btn had been clicked + wrapper.find('#reset').simulate('reset'); + await timeout(); + expect(onMetaChange).toHaveBeenNthCalledWith(3, true); + expect(onMetaChange).toHaveBeenNthCalledWith(4, false); }); });