From 76bcbb7e31ab6f045e91750bf2abe9f69df37cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Miernik?= Date: Thu, 23 Jul 2020 11:58:17 +0200 Subject: [PATCH] Fixed AutoForm validation (fixes #769). --- packages/uniforms/__tests__/AutoForm.tsx | 17 +++++++++++++++++ packages/uniforms/src/AutoForm.tsx | 4 ---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/uniforms/__tests__/AutoForm.tsx b/packages/uniforms/__tests__/AutoForm.tsx index 999361008..980d55560 100644 --- a/packages/uniforms/__tests__/AutoForm.tsx +++ b/packages/uniforms/__tests__/AutoForm.tsx @@ -40,6 +40,23 @@ describe('AutoForm', () => { expect(onChange).toHaveBeenLastCalledWith('a', '2'); }); + it('validates', () => { + // FIXME: AutoForm is not a valid Component. + const wrapper = mount( + , + ); + + wrapper.instance().submit(); + + expect(validator).toHaveBeenCalledTimes(1); + expect(validator).toHaveBeenLastCalledWith({}); + + wrapper.instance().getContext().onChange('a', '1'); + + expect(validator).toHaveBeenCalledTimes(2); + expect(validator).toHaveBeenLastCalledWith({ a: '1' }); + }); + it('calls `onChangeModel`', () => { // FIXME: AutoForm is not a valid Component. const wrapper = mount( diff --git a/packages/uniforms/src/AutoForm.tsx b/packages/uniforms/src/AutoForm.tsx index b15f4fad7..907a6471a 100644 --- a/packages/uniforms/src/AutoForm.tsx +++ b/packages/uniforms/src/AutoForm.tsx @@ -74,10 +74,6 @@ export function Auto(Base: Base) { model: this.props.model, } as Partial; } - - onValidate() { - return this.onValidateModel(this.getContextModel()); - } } return AutoForm;