File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
app/Component/Field/__tests__ Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -35,4 +35,21 @@ describe('SelectField', () => {
35
35
36
36
expect ( values ) . toEqual ( { 'my_field' : '2' } ) ;
37
37
} ) ;
38
+
39
+ it ( 'should get a multi select with correct props and state' , ( ) => {
40
+ const choices = [
41
+ { value : 1 , label : 'First choice' } ,
42
+ { value : 2 , label : 'Second choice' } ,
43
+ { value : 3 , label : 'Third choice' }
44
+ ] ;
45
+ const value = [ 2 , 3 ] ;
46
+ const instance = TestUtils . renderIntoDocument ( < SelectField name = "my_field" value = { value } multiple = { true } choices = { choices } updateField = { onChange } /> ) ;
47
+ const select = TestUtils . findRenderedComponentWithType ( instance , Select ) ;
48
+
49
+ expect ( select . state . value ) . toBe ( '2,3' ) ;
50
+
51
+ select . selectValue ( '1' ) ;
52
+
53
+ expect ( values ) . toEqual ( { 'my_field' : [ '2' , '3' , '1' ] } ) ;
54
+ } ) ;
38
55
} ) ;
You can’t perform that action at this time.
0 commit comments