@@ -27,23 +27,6 @@ describe('Select.combobox', () => {
27
27
expect ( wrapper . state ( ) . inputValue ) . toBe ( '1' ) ;
28
28
} ) ;
29
29
30
- it ( 'display correct label when value changes' , ( ) => {
31
- const wrapper = mount (
32
- < Select
33
- combobox
34
- labelInValue
35
- value = { { value : '' , key : '' } }
36
- optionLabelProp = "children"
37
- >
38
- < Option value = "1" > One</ Option >
39
- < Option value = "2" > Two</ Option >
40
- </ Select >
41
- ) ;
42
-
43
- wrapper . setProps ( { value : { label : 'One' , key : '1' } } ) ;
44
- expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toBe ( 'One' ) ;
45
- } ) ;
46
-
47
30
it ( 'fire change event immediately when user inputing' , ( ) => {
48
31
const handleChange = jest . fn ( ) ;
49
32
const wrapper = mount (
@@ -72,4 +55,60 @@ describe('Select.combobox', () => {
72
55
dropdownWrapper . find ( 'MenuItem' ) . first ( ) . simulate ( 'click' ) ;
73
56
expect ( wrapper . state ( ) . inputValue ) . toBe ( '1' ) ;
74
57
} ) ;
58
+
59
+ describe ( 'input value' , ( ) => {
60
+ const createSelect = ( props ) => mount (
61
+ < Select
62
+ combobox
63
+ optionLabelProp = "children"
64
+ { ...props }
65
+ >
66
+ < Option value = "1" > One</ Option >
67
+ < Option value = "2" > Two</ Option >
68
+ </ Select >
69
+ ) ;
70
+
71
+ describe ( 'labelInValue is false' , ( ) => {
72
+ it ( 'displays correct input value for defaultValue' , ( ) => {
73
+ const wrapper = createSelect ( {
74
+ defaultValue : '1' ,
75
+ } ) ;
76
+ expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toBe ( 'One' ) ;
77
+ } ) ;
78
+
79
+ it ( 'displays correct input value for value' , ( ) => {
80
+ const wrapper = createSelect ( {
81
+ value : '1' ,
82
+ } ) ;
83
+ expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toBe ( 'One' ) ;
84
+ } ) ;
85
+ } ) ;
86
+
87
+ describe ( 'labelInValue is true' , ( ) => {
88
+ it ( 'displays correct input value for defaultValue' , ( ) => {
89
+ const wrapper = createSelect ( {
90
+ labelInValue : true ,
91
+ defaultValue : { key : '1' , label : 'One' } ,
92
+ } ) ;
93
+ expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toBe ( 'One' ) ;
94
+ } ) ;
95
+
96
+ it ( 'displays correct input value for value' , ( ) => {
97
+ const wrapper = createSelect ( {
98
+ labelInValue : true ,
99
+ value : { key : '1' , label : 'One' } ,
100
+ } ) ;
101
+ expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toBe ( 'One' ) ;
102
+ } ) ;
103
+
104
+ it ( 'displays correct input value when value changes' , ( ) => {
105
+ const wrapper = createSelect ( {
106
+ labelInValue : true ,
107
+ value : { key : '' } ,
108
+ } ) ;
109
+ wrapper . setProps ( { value : { key : '1' , label : 'One' } } ) ;
110
+ expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toBe ( 'One' ) ;
111
+ } ) ;
112
+ } ) ;
113
+ } ) ;
75
114
} ) ;
0 commit comments