File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
packages/react-form-renderer/src/tests/form-renderer Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1723,4 +1723,34 @@ describe('renderForm function', () => {
17231723 expect ( wrapper . find ( 'label' ) . text ( ) ) . toEqual ( label ) ;
17241724 expect ( wrapper . find ( 'label' ) . props ( ) . id ) . toEqual ( id ) ;
17251725 } ) ;
1726+
1727+ describe ( '#initialValues' , ( ) => {
1728+ it ( 'initialValues has a higher priority than initialValue' , ( ) => {
1729+ const onSubmit = jest . fn ( ) ;
1730+ const wrapper = mount (
1731+ < FormRenderer
1732+ FormTemplate = { ( props ) => < FormTemplate { ...props } /> }
1733+ componentMapper = { {
1734+ 'custom-component' : TextField ,
1735+ } }
1736+ schema = { {
1737+ fields : [
1738+ {
1739+ component : 'custom-component' ,
1740+ name : 'testField' ,
1741+ initialValue : 'lower-priority' ,
1742+ } ,
1743+ ] ,
1744+ } }
1745+ onSubmit = { ( values ) => onSubmit ( values ) }
1746+ initialValues = { { testField : 'higher-priority' } }
1747+ />
1748+ ) ;
1749+
1750+ expect ( wrapper . find ( 'input' ) . instance ( ) . value ) . toEqual ( 'higher-priority' ) ;
1751+
1752+ wrapper . find ( 'form' ) . simulate ( 'submit' ) ;
1753+ expect ( onSubmit ) . toHaveBeenCalledWith ( { testField : 'higher-priority' } ) ;
1754+ } ) ;
1755+ } ) ;
17261756} ) ;
You can’t perform that action at this time.
0 commit comments