@@ -884,5 +884,69 @@ describe('renderForm function', () => {
884884 mountInitializedField ( wrapper ) ;
885885 expectSchemaInitialValue ( wrapper ) ;
886886 } ) ;
887+
888+ it ( 'should set false value in initializeOnMount' , ( ) => {
889+ layoutMapper = {
890+ [ layoutComponents . FORM_WRAPPER ] : ( { children, ...props } ) => < form { ...props } > { children } </ form > ,
891+ [ layoutComponents . BUTTON ] : ( { label, ...rest } ) => < button { ...rest } > { label } </ button > ,
892+ [ layoutComponents . BUTTON_GROUP ] : ( { children } ) => < div > { children } </ div > ,
893+ [ layoutComponents . TITLE ] : ( { children } ) => < div > { children } </ div > ,
894+ [ layoutComponents . DESCRIPTION ] : ( { children } ) => < div > { children } </ div > ,
895+ } ;
896+
897+ const schema = {
898+ fields : [ {
899+ component : components . TEXT_FIELD ,
900+ name : 'input' ,
901+ } , {
902+ component : components . TEXT_FIELD ,
903+ name : 'unmounted' ,
904+ initialValue : false ,
905+ initializeOnMount : true ,
906+ condition : {
907+ when : 'input' ,
908+ is : 'show_false' ,
909+ } ,
910+ } , {
911+ component : components . TEXT_FIELD ,
912+ name : 'unmounted' ,
913+ initialValue : true ,
914+ initializeOnMount : true ,
915+ condition : {
916+ when : 'input' ,
917+ is : 'show_true' ,
918+ } ,
919+ } ] ,
920+ } ;
921+
922+ const onSubmit = jest . fn ( ) ;
923+
924+ const wrapper = mount (
925+ < FormRenderer
926+ layoutMapper = { layoutMapper }
927+ formFieldsMapper = { {
928+ [ components . TEXT_FIELD ] : TextField ,
929+ } }
930+ schema = { schema }
931+ onSubmit = { onSubmit }
932+ />
933+ ) ;
934+
935+ wrapper . find ( 'input' ) . first ( ) . simulate ( 'change' , { target : { value : 'show_true' } } ) ;
936+ wrapper . update ( ) ;
937+
938+ wrapper . find ( 'form' ) . simulate ( 'submit' ) ;
939+
940+ expect ( onSubmit ) . toHaveBeenCalledWith ( { input : 'show_true' , unmounted : true } , expect . any ( Object ) , expect . any ( Function ) ) ;
941+ onSubmit . mockClear ( ) ;
942+
943+ wrapper . find ( 'input' ) . first ( ) . simulate ( 'change' , { target : { value : 'show_false' } } ) ;
944+ wrapper . update ( ) ;
945+
946+ wrapper . find ( 'form' ) . simulate ( 'submit' ) ;
947+ wrapper . update ( ) ;
948+
949+ expect ( onSubmit ) . toHaveBeenCalledWith ( { input : 'show_false' , unmounted : false } , expect . any ( Object ) , expect . any ( Function ) ) ;
950+ } ) ;
887951 } ) ;
888952} ) ;
0 commit comments