File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2367,4 +2367,28 @@ describe('Select.Basic', () => {
2367
2367
expect ( element [ 0 ] ) . not . toHaveClass ( 'rc-select-item-option-disabled' ) ;
2368
2368
expect ( element [ 1 ] ) . toHaveClass ( 'rc-select-item-option-disabled' ) ;
2369
2369
} ) ;
2370
+
2371
+ it ( 'click item and blur should trigger onBlur but not trigger onSearch' , ( ) => {
2372
+ const onSearch = jest . fn ( ) ;
2373
+ const onBlur = jest . fn ( ) ;
2374
+
2375
+ const Demo = ( ) => (
2376
+ < Select onSearch = { onSearch } showSearch onBlur = { onBlur } >
2377
+ < Option value = "11" > 11</ Option >
2378
+ < Option value = "22" > 22</ Option >
2379
+ < Option value = "33" > 33</ Option >
2380
+ </ Select >
2381
+ ) ;
2382
+
2383
+ const { container } = render ( < Demo /> ) ;
2384
+ const input = container . querySelector ( 'input' ) ;
2385
+ fireEvent . change ( input , { target : { value : '1' } } ) ;
2386
+ fireEvent . click (
2387
+ container . querySelectorAll ( '.rc-select-dropdown .rc-select-item-option-content' ) [ 0 ] ,
2388
+ ) ;
2389
+ fireEvent . blur ( input ) ;
2390
+ expect ( container . querySelector ( '.rc-select-dropdown-hidden' ) ) . toBeTruthy ( ) ;
2391
+ expect ( onSearch ) . toHaveBeenCalledTimes ( 1 ) ;
2392
+ expect ( onBlur ) . toHaveBeenCalledTimes ( 1 ) ;
2393
+ } ) ;
2370
2394
} ) ;
You can’t perform that action at this time.
0 commit comments