@@ -7,6 +7,7 @@ import FormTemplate from '../form-template';
77import componentMapper from '../component-mapper' ;
88import { Select , MultiSelect , ComboBox } from 'carbon-components-react' ;
99import { multiOnChange } from '../select' ;
10+ import { getMultiValue } from '../select/select' ;
1011
1112describe ( '<Select />' , ( ) => {
1213 it ( 'renders select' , ( ) => {
@@ -193,4 +194,38 @@ describe('<Select />', () => {
193194 expect ( input . onChange ) . toHaveBeenCalledWith ( [ { value : '123' } , { value : '345' } ] ) ;
194195 } ) ;
195196 } ) ;
197+
198+ describe ( 'getMultiValue' , ( ) => {
199+ let value ;
200+ let options ;
201+
202+ beforeEach ( ( ) => {
203+ value = undefined ;
204+ options = [ ] ;
205+ } ) ;
206+
207+ it ( 'undefined' , ( ) => {
208+ expect ( getMultiValue ( value , options ) ) . toEqual ( [ ] ) ;
209+ } ) ;
210+
211+ it ( 'array' , ( ) => {
212+ value = [ 'dogs' ] ;
213+ options = [
214+ { label : 'cats' , value : 'cats' } ,
215+ { label : 'dogs' , value : 'dogs' }
216+ ] ;
217+
218+ expect ( getMultiValue ( value , options ) ) . toEqual ( [ { label : 'dogs' , value : 'dogs' } ] ) ;
219+ } ) ;
220+
221+ it ( 'single' , ( ) => {
222+ value = 'dogs' ;
223+ options = [
224+ { label : 'cats' , value : 'cats' } ,
225+ { label : 'dogs' , value : 'dogs' }
226+ ] ;
227+
228+ expect ( getMultiValue ( value , options ) ) . toEqual ( [ { label : 'dogs' , value : 'dogs' } ] ) ;
229+ } ) ;
230+ } ) ;
196231} ) ;
0 commit comments