@@ -28,7 +28,6 @@ describe('data types', () => {
2828 let initialProps ;
2929 beforeEach ( ( ) => {
3030 initialProps = {
31- onSubmit : jest . fn ( ) ,
3231 layoutMapper,
3332 formFieldsMapper : {
3433 [ componentTypes . TEXT_FIELD ] : DataTypeInput ,
@@ -62,7 +61,10 @@ describe('data types', () => {
6261 expect ( onSubmit ) . not . toHaveBeenCalled ( ) ;
6362
6463 input . simulate ( 'change' , { target : { value : '123' } } ) ;
65- wrapper . find ( 'button' ) . first ( ) . simulate ( 'click' ) ;
64+ wrapper . update ( ) ;
65+
66+ wrapper . find ( 'form' ) . first ( ) . simulate ( 'submit' ) ;
67+
6668 expect ( onSubmit ) . toHaveBeenCalledWith ( expect . objectContaining ( {
6769 'data-type-text' : 123 ,
6870 } ) , expect . anything ( ) , expect . anything ( ) ) ;
@@ -82,7 +84,7 @@ describe('data types', () => {
8284 const wrapper = mount ( < FormRenderer { ...initialProps } onSubmit = { onSubmit } schema = { propSchema } /> ) ;
8385 const input = wrapper . find ( 'input' ) ;
8486 input . simulate ( 'change' , { target : { value : '123' } } ) ;
85- wrapper . find ( 'button ' ) . first ( ) . simulate ( 'click ' ) ;
87+ wrapper . find ( 'form ' ) . first ( ) . simulate ( 'submit ' ) ;
8688 expect ( onSubmit ) . toHaveBeenCalledWith ( expect . objectContaining ( {
8789 'data-type-text' : 123 ,
8890 } ) , expect . anything ( ) , expect . anything ( ) ) ;
@@ -102,7 +104,7 @@ describe('data types', () => {
102104 const wrapper = mount ( < FormRenderer { ...initialProps } onSubmit = { onSubmit } schema = { renderSchema } /> ) ;
103105 const input = wrapper . find ( 'input' ) ;
104106 input . simulate ( 'change' , { target : { value : '123' } } ) ;
105- wrapper . find ( 'button ' ) . first ( ) . simulate ( 'click ' ) ;
107+ wrapper . find ( 'form ' ) . first ( ) . simulate ( 'submit ' ) ;
106108 expect ( onSubmit ) . toHaveBeenCalledWith ( expect . objectContaining ( {
107109 'data-type-text' : 123 ,
108110 } ) , expect . anything ( ) , expect . anything ( ) ) ;
@@ -122,7 +124,7 @@ describe('data types', () => {
122124 const wrapper = mount ( < FormRenderer { ...initialProps } onSubmit = { onSubmit } schema = { childSchema } /> ) ;
123125 const input = wrapper . find ( 'input' ) ;
124126 input . simulate ( 'change' , { target : { value : '123' } } ) ;
125- wrapper . find ( 'button ' ) . first ( ) . simulate ( 'click ' ) ;
127+ wrapper . find ( 'form ' ) . first ( ) . simulate ( 'submit ' ) ;
126128 expect ( onSubmit ) . toHaveBeenCalledWith ( expect . objectContaining ( {
127129 'data-type-text' : 123 ,
128130 } ) , expect . anything ( ) , expect . anything ( ) ) ;
0 commit comments