File tree Expand file tree Collapse file tree 2 files changed +77
-1
lines changed Expand file tree Collapse file tree 2 files changed +77
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export default function useSearchConfig(showSearch?: CascaderProps['showSearch']
22
22
}
23
23
24
24
if ( ( searchConfig . limit as number ) <= 0 ) {
25
- delete searchConfig . limit ;
25
+ searchConfig . limit = false ;
26
26
27
27
if ( process . env . NODE_ENV !== 'production' ) {
28
28
warning ( false , "'limit' of showSearch should be positive number or false." ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import Cascader from '../src' ;
3
+ import type { ReactWrapper } from './enzyme' ;
4
+ import { mount } from './enzyme' ;
5
+
6
+ describe ( 'Cascader.Search' , ( ) => {
7
+ function doSearch ( wrapper : ReactWrapper , search : string ) {
8
+ wrapper . find ( 'input' ) . simulate ( 'change' , {
9
+ target : {
10
+ value : search ,
11
+ } ,
12
+ } ) ;
13
+ }
14
+ const options = [
15
+ {
16
+ children : [ ] as any [ ] ,
17
+ isParent : true ,
18
+ label : 'Asia' ,
19
+ value : 'Asia' ,
20
+ } ,
21
+ ] ;
22
+ for ( let i = 0 ; i < 100 ; i ++ ) {
23
+ options [ 0 ] . children . push ( {
24
+ label : 'label' + i ,
25
+ value : 'value' + i ,
26
+ } ) ;
27
+ }
28
+
29
+ it ( 'limit' , ( ) => {
30
+ const wrapper = mount (
31
+ < Cascader
32
+ options = { options }
33
+ open
34
+ showSearch = { {
35
+ limit : false ,
36
+ } }
37
+ /> ,
38
+ ) ;
39
+
40
+ doSearch ( wrapper , 'as' ) ;
41
+ const itemList = wrapper . find ( 'div.rc-cascader-menu-item-content' ) ;
42
+ expect ( itemList ) . toHaveLength ( 100 ) ;
43
+ } ) ;
44
+
45
+ it ( 'limit' , ( ) => {
46
+ const wrapper = mount (
47
+ < Cascader
48
+ options = { options }
49
+ open
50
+ showSearch = { {
51
+ limit : 0 ,
52
+ } }
53
+ /> ,
54
+ ) ;
55
+
56
+ doSearch ( wrapper , 'as' ) ;
57
+ const itemList = wrapper . find ( 'div.rc-cascader-menu-item-content' ) ;
58
+ expect ( itemList ) . toHaveLength ( 100 ) ;
59
+ } ) ;
60
+
61
+ it ( 'limit' , ( ) => {
62
+ const wrapper = mount (
63
+ < Cascader
64
+ options = { options }
65
+ open
66
+ showSearch = { {
67
+ limit : 20 ,
68
+ } }
69
+ /> ,
70
+ ) ;
71
+
72
+ doSearch ( wrapper , 'as' ) ;
73
+ const itemList = wrapper . find ( 'div.rc-cascader-menu-item-content' ) ;
74
+ expect ( itemList ) . toHaveLength ( 20 ) ;
75
+ } ) ;
76
+ } ) ;
You can’t perform that action at this time.
0 commit comments