@@ -6,12 +6,7 @@ import Select, { Option, SelectProps } from '../src';
66import focusTest from './shared/focusTest' ;
77import keyDownTest from './shared/keyDownTest' ;
88import openControlledTest from './shared/openControlledTest' ;
9- import {
10- expectOpen ,
11- toggleOpen ,
12- selectItem ,
13- injectRunAllTimers ,
14- } from './utils/common' ;
9+ import { expectOpen , toggleOpen , selectItem , injectRunAllTimers } from './utils/common' ;
1510import allowClearTest from './shared/allowClearTest' ;
1611import throwOptionValue from './shared/throwOptionValue' ;
1712
@@ -71,10 +66,10 @@ describe('Select.Combobox', () => {
7166 ) ;
7267
7368 wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : '1' } } ) ;
74- expect ( handleChange ) . toBeCalledWith ( '1' , undefined ) ;
69+ expect ( handleChange ) . toHaveBeenCalledWith ( '1' , { } ) ;
7570
7671 wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : '22' } } ) ;
77- expect ( handleChange ) . toBeCalledWith (
72+ expect ( handleChange ) . toHaveBeenCalledWith (
7873 '22' ,
7974 expect . objectContaining ( {
8075 children : '22' ,
@@ -134,13 +129,15 @@ describe('Select.Combobox', () => {
134129 public state = {
135130 data : [ ] ,
136131 } ;
132+
137133 public handleChange = ( ) => {
138134 setTimeout ( ( ) => {
139135 this . setState ( {
140136 data : [ { key : '1' , label : '1' } , { key : '2' , label : '2' } ] ,
141137 } ) ;
142138 } , 500 ) ;
143139 } ;
140+
144141 public render ( ) {
145142 const options = this . state . data . map ( item => < Option key = { item . key } > { item . label } </ Option > ) ;
146143 return (
@@ -171,13 +168,15 @@ describe('Select.Combobox', () => {
171168 public state = {
172169 data : [ { key : '1' , label : '1' } , { key : '2' , label : '2' } ] ,
173170 } ;
171+
174172 public onSelect = ( ) => {
175173 setTimeout ( ( ) => {
176174 this . setState ( {
177175 data : [ { key : '3' , label : '3' } , { key : '4' , label : '4' } ] ,
178176 } ) ;
179177 } , 500 ) ;
180178 } ;
179+
181180 public render ( ) {
182181 const options = this . state . data . map ( item => < Option key = { item . key } > { item . label } </ Option > ) ;
183182 return (
@@ -208,27 +207,21 @@ describe('Select.Combobox', () => {
208207 const handleChange = jest . fn ( ) ;
209208 const handleSelect = jest . fn ( ) ;
210209 const wrapper = mount (
211- < Select
212- mode = "combobox"
213- backfill = { true }
214- open = { true }
215- onChange = { handleChange }
216- onSelect = { handleSelect }
217- >
210+ < Select mode = "combobox" backfill open onChange = { handleChange } onSelect = { handleSelect } >
218211 < Option value = "One" > One</ Option >
219212 < Option value = "Two" > Two</ Option >
220213 </ Select > ,
221214 ) ;
222215 const input = wrapper . find ( 'input' ) ;
223216 input . simulate ( 'keyDown' , { which : KeyCode . DOWN } ) ;
224217 expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toEqual ( 'One' ) ;
225- expect ( handleChange ) . not . toBeCalled ( ) ;
226- expect ( handleSelect ) . not . toBeCalled ( ) ;
218+ expect ( handleChange ) . not . toHaveBeenCalled ( ) ;
219+ expect ( handleSelect ) . not . toHaveBeenCalled ( ) ;
227220
228221 input . simulate ( 'keyDown' , { which : KeyCode . ENTER } ) ;
229222 expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toEqual ( 'One' ) ;
230- expect ( handleChange ) . toBeCalledWith ( 'One' , expect . objectContaining ( { value : 'One' } ) ) ;
231- expect ( handleSelect ) . toBeCalledWith ( 'One' , expect . objectContaining ( { value : 'One' } ) ) ;
223+ expect ( handleChange ) . toHaveBeenCalledWith ( 'One' , expect . objectContaining ( { value : 'One' } ) ) ;
224+ expect ( handleSelect ) . toHaveBeenCalledWith ( 'One' , expect . objectContaining ( { value : 'One' } ) ) ;
232225 } ) ;
233226
234227 it ( "should hide clear icon when value is ''" , ( ) => {
@@ -283,9 +276,9 @@ describe('Select.Combobox', () => {
283276 public render ( ) {
284277 return (
285278 < Select mode = "combobox" onChange = { this . updateOptions } >
286- { this . state . options . map ( opt => {
287- return < Option key = { opt } > { opt } </ Option > ;
288- } ) }
279+ { this . state . options . map ( opt => (
280+ < Option key = { opt } > { opt } </ Option >
281+ ) ) }
289282 </ Select >
290283 ) ;
291284 }
@@ -328,7 +321,7 @@ describe('Select.Combobox', () => {
328321 } ) ;
329322 jest . runAllTimers ( ) ;
330323 wrapper . update ( ) ;
331- expect ( onDropdownVisibleChange ) . toBeCalledWith ( false ) ;
324+ expect ( onDropdownVisibleChange ) . toHaveBeenCalledWith ( false ) ;
332325 jest . useRealTimers ( ) ;
333326 } ) ;
334327} ) ;
0 commit comments