@@ -161,6 +161,8 @@ describe('FormBuilder', () => {
161
161
expect ( mockEvent ) . toHaveBeenCalledTimes ( 0 ) ;
162
162
createButton . simulate ( 'click' ) ;
163
163
expect ( mockEvent ) . toHaveBeenCalledTimes ( 1 ) ;
164
+
165
+ const cardInputs = wrapper . first ( ) . find ( 'input' ) ;
164
166
mockEvent . mockClear ( ) ;
165
167
} ) ;
166
168
@@ -624,73 +626,51 @@ describe('FormBuilder', () => {
624
626
mockEvent . mockClear ( ) ;
625
627
} ) ;
626
628
627
- it ( "should allow changing of a Section element's 'required' property" , ( ) => {
628
- const sectionUiSchema = {
629
- definitions : {
630
- full_names : {
631
- 'ui:order' : [ 'first_names' , 'last_names' ] ,
629
+ it ( 'should edit card slug and override ui:schema with updated slug' , ( ) => {
630
+ let jsonSchema = {
631
+ properties : {
632
+ newInput1 : {
633
+ title : 'New Input 1' ,
634
+ type : 'string' ,
632
635
} ,
633
636
} ,
634
- user_full_names : {
635
- 'ui:order' : [ 'first_names' , 'last_names' ] ,
636
- } ,
637
- 'ui:order' : [ 'user_full_names' ] ,
638
637
} ;
639
638
640
- const sectionJsonSchema = {
641
- definitions : {
642
- full_names : {
643
- title : 'Full Names' ,
644
- type : 'object' ,
645
- description : 'This is a composite field' ,
646
- properties : {
647
- first_names : {
648
- title : 'First Names' ,
649
- type : 'string' ,
650
- } ,
651
- last_names : {
652
- title : 'Last Names' ,
653
- type : 'string' ,
654
- } ,
655
- } ,
656
- dependencies : { } ,
657
- required : [ ] ,
658
- } ,
659
- } ,
660
- properties : {
661
- user_full_names : {
662
- $ref : '#/definitions/full_names' ,
663
- title : 'User Full Names' ,
664
- description : 'Full names description' ,
665
- required : [ ] ,
666
- } ,
639
+ let uiSchema = {
640
+ 'ui:order' : [ 'newInput1' ] ,
641
+ newInput1 : {
642
+ 'ui:column' : '3' ,
667
643
} ,
668
- dependencies : { } ,
669
- required : [ ] ,
670
- type : 'object' ,
671
644
} ;
672
645
673
646
const innerProps = {
674
647
...props ,
675
- schema : JSON . stringify ( sectionJsonSchema ) ,
676
- uiSchema : JSON . stringify ( sectionUiSchema ) ,
648
+
649
+ schema : JSON . stringify ( jsonSchema ) ,
650
+ uischema : JSON . stringify ( uiSchema ) ,
651
+ onChange : ( newSchema , newUiSchema ) => {
652
+ jsonSchema = newSchema ;
653
+ uiSchema = newUiSchema ;
654
+ } ,
677
655
} ;
678
656
679
657
const div = document . createElement ( 'div' ) ;
680
658
document . body . appendChild ( div ) ;
681
659
const wrapper = mount ( < FormBuilder { ...innerProps } /> , { attachTo : div } ) ;
660
+ const cardInputs = wrapper . find ( '.card-container' ) . first ( ) . find ( 'input' ) ;
682
661
683
- const subFieldCheckbox = wrapper . find ( { type : 'checkbox' } ) ;
684
-
685
- const firstNamesCheckbox = subFieldCheckbox . at ( 0 ) ;
686
-
687
- firstNamesCheckbox . simulate ( 'change' , { target : { checked : true } } ) ;
662
+ cardInputs . at ( 0 ) . simulate ( 'blur' , {
663
+ target : { value : 'nameA' } ,
664
+ } ) ;
688
665
689
- const updatedSchema = JSON . parse ( mockEvent . mock . calls [ 0 ] [ 0 ] ) ;
666
+ const expected = {
667
+ 'ui:order' : [ 'nameA' ] ,
668
+ nameA : {
669
+ 'ui:column' : '3' ,
670
+ } ,
671
+ } ;
690
672
691
- expect ( updatedSchema . properties . user_full_names . required ) . toEqual ( [
692
- 'first_names' ,
693
- ] ) ;
673
+ expect ( JSON . parse ( uiSchema ) ) . toEqual ( expected ) ;
694
674
mockEvent . mockClear ( ) ;
695
675
} ) ;
696
676
} ) ;
0 commit comments