@@ -4,7 +4,8 @@ import React from 'react';
4
4
import { act } from 'react-dom/test-utils' ;
5
5
import { resetWarned } from 'rc-util/lib/warning' ;
6
6
import { spyElementPrototype } from 'rc-util/lib/test/domHook' ;
7
- import Select , { OptGroup , Option , SelectProps } from '../src' ;
7
+ import type { SelectProps } from '../src' ;
8
+ import Select , { OptGroup , Option } from '../src' ;
8
9
import focusTest from './shared/focusTest' ;
9
10
import blurTest from './shared/blurTest' ;
10
11
import keyDownTest from './shared/keyDownTest' ;
@@ -148,18 +149,12 @@ describe('Select.Basic', () => {
148
149
</ Select > ,
149
150
) ;
150
151
expect (
151
- wrapper1
152
- . find ( '.rc-select-dropdown' )
153
- . first ( )
154
- . hasClass ( 'rc-select-dropdown-empty' ) ,
152
+ wrapper1 . find ( '.rc-select-dropdown' ) . first ( ) . hasClass ( 'rc-select-dropdown-empty' ) ,
155
153
) . toBeFalsy ( ) ;
156
154
157
155
const wrapper2 = mount ( < Select open /> ) ;
158
156
expect (
159
- wrapper2
160
- . find ( '.rc-select-dropdown' )
161
- . first ( )
162
- . hasClass ( 'rc-select-dropdown-empty' ) ,
157
+ wrapper2 . find ( '.rc-select-dropdown' ) . first ( ) . hasClass ( 'rc-select-dropdown-empty' ) ,
163
158
) . toBeTruthy ( ) ;
164
159
} ) ;
165
160
@@ -189,7 +184,7 @@ describe('Select.Basic', () => {
189
184
expect (
190
185
wrapper
191
186
. find ( '.rc-select-item-option-selected div.rc-select-item-option-content' )
192
- . map ( node => node . text ( ) ) ,
187
+ . map ( ( node ) => node . text ( ) ) ,
193
188
) . toEqual ( [ '1' , '2' ] ) ;
194
189
} ) ;
195
190
@@ -250,12 +245,7 @@ describe('Select.Basic', () => {
250
245
< Option value = "2" > Two</ Option >
251
246
</ Select > ,
252
247
) ;
253
- expect (
254
- wrapper
255
- . find ( 'input' )
256
- . getDOMNode ( )
257
- . getAttribute ( 'readonly' ) ,
258
- ) . toBeFalsy ( ) ;
248
+ expect ( wrapper . find ( 'input' ) . getDOMNode ( ) . getAttribute ( 'readonly' ) ) . toBeFalsy ( ) ;
259
249
} ) ;
260
250
261
251
it ( 'filter options by "value" prop by default' , ( ) => {
@@ -657,7 +647,7 @@ describe('Select.Basic', () => {
657
647
} ) ;
658
648
} ) ;
659
649
660
- [ KeyCode . ENTER , KeyCode . DOWN ] . forEach ( keyCode => {
650
+ [ KeyCode . ENTER , KeyCode . DOWN ] . forEach ( ( keyCode ) => {
661
651
it ( 'open on key press' , ( ) => {
662
652
const wrapper = mount ( < Select /> ) ;
663
653
wrapper . find ( 'input' ) . simulate ( 'keyDown' , { keyCode } ) ;
@@ -726,7 +716,7 @@ describe('Select.Basic', () => {
726
716
open : true ,
727
717
} ;
728
718
729
- public onDropdownVisibleChange = open => {
719
+ public onDropdownVisibleChange = ( open ) => {
730
720
this . setState ( { open } ) ;
731
721
} ;
732
722
@@ -779,6 +769,7 @@ describe('Select.Basic', () => {
779
769
onCompositionStart = { onCompositionStart }
780
770
onCompositionEnd = { onCompositionEnd }
781
771
ref = { textareaRef }
772
+ className = "custom-input"
782
773
/>
783
774
) }
784
775
>
@@ -800,6 +791,7 @@ describe('Select.Basic', () => {
800
791
801
792
selectItem ( wrapper ) ;
802
793
expect ( wrapper . find ( 'textarea' ) . props ( ) . value ) . toEqual ( '1' ) ;
794
+ expect ( wrapper . find ( 'textarea' ) . hasClass ( 'custom-input' ) ) . toBe ( true ) ;
803
795
expect ( mouseDownPreventDefault ) . not . toHaveBeenCalled ( ) ;
804
796
expect ( onKeyDown ) . toHaveBeenCalled ( ) ;
805
797
expect ( onChange ) . toHaveBeenCalled ( ) ;
@@ -907,7 +899,7 @@ describe('Select.Basic', () => {
907
899
} ) ;
908
900
909
901
it ( 'warns on invalid children' , ( ) => {
910
- const Foo = value => < div > foo{ value } </ div > ;
902
+ const Foo = ( value ) => < div > foo{ value } </ div > ;
911
903
const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => null ) ;
912
904
mount (
913
905
< Select open >
@@ -1031,7 +1023,7 @@ describe('Select.Basic', () => {
1031
1023
const wrapper = mount (
1032
1024
< Select
1033
1025
open
1034
- dropdownRender = { menu => (
1026
+ dropdownRender = { ( menu ) => (
1035
1027
< div >
1036
1028
< div className = "dropdown-custom-node" > CUSTOM NODE</ div >
1037
1029
{ menu }
@@ -1053,7 +1045,7 @@ describe('Select.Basic', () => {
1053
1045
const wrapper = mount (
1054
1046
< Select
1055
1047
onMouseDown = { onMouseDown }
1056
- dropdownRender = { menu => (
1048
+ dropdownRender = { ( menu ) => (
1057
1049
< div >
1058
1050
< div id = "dropdown-custom-node" onClick = { onChildClick } >
1059
1051
CUSTOM NODE
@@ -1202,12 +1194,7 @@ describe('Select.Basic', () => {
1202
1194
/> ,
1203
1195
) ;
1204
1196
toggleOpen ( wrapper ) ;
1205
- expect (
1206
- wrapper
1207
- . find ( '.rc-select-dropdown' )
1208
- . last ( )
1209
- . props ( ) . style . minWidth ,
1210
- ) . toBe ( 1000 ) ;
1197
+ expect ( wrapper . find ( '.rc-select-dropdown' ) . last ( ) . props ( ) . style . minWidth ) . toBe ( 1000 ) ;
1211
1198
1212
1199
// dropdownMatchSelectWidth is false means close virtual scroll
1213
1200
expect ( wrapper . find ( '.rc-select-item' ) ) . toHaveLength ( options . length ) ;
@@ -1504,7 +1491,7 @@ describe('Select.Basic', () => {
1504
1491
} ) ;
1505
1492
1506
1493
describe ( 'reset value to undefined should reset display value' , ( ) => {
1507
- [ undefined ] . forEach ( value => {
1494
+ [ undefined ] . forEach ( ( value ) => {
1508
1495
it ( `to ${ value } ` , ( ) => {
1509
1496
const wrapper = mount ( < Select value = "light" /> ) ;
1510
1497
expect ( wrapper . find ( '.rc-select-selection-item' ) . text ( ) ) . toEqual ( 'light' ) ;
@@ -1588,7 +1575,12 @@ describe('Select.Basic', () => {
1588
1575
</ Select > ,
1589
1576
) ;
1590
1577
1591
- [ [ 1 , '1' ] , [ null , 'No' ] , [ 0 , '0' ] , [ '' , 'Empty' ] ] . forEach ( ( [ value , showValue ] , index ) => {
1578
+ [
1579
+ [ 1 , '1' ] ,
1580
+ [ null , 'No' ] ,
1581
+ [ 0 , '0' ] ,
1582
+ [ '' , 'Empty' ] ,
1583
+ ] . forEach ( ( [ value , showValue ] , index ) => {
1592
1584
toggleOpen ( wrapper ) ;
1593
1585
selectItem ( wrapper , index ) ;
1594
1586
expect ( onChange ) . toHaveBeenCalledWith ( value , expect . anything ( ) ) ;
@@ -1632,11 +1624,7 @@ describe('Select.Basic', () => {
1632
1624
// This can not test function called with jest spy, coverage only
1633
1625
it ( 'mouse enter to refresh' , ( ) => {
1634
1626
const wrapper = mount ( < Select options = { [ { value : 903 , label : 'Bamboo' } ] } open /> ) ;
1635
- wrapper
1636
- . find ( 'List' )
1637
- . find ( 'div' )
1638
- . first ( )
1639
- . simulate ( 'mouseenter' ) ;
1627
+ wrapper . find ( 'List' ) . find ( 'div' ) . first ( ) . simulate ( 'mouseenter' ) ;
1640
1628
} ) ;
1641
1629
1642
1630
it ( 'filterSort should work' , ( ) => {
@@ -1657,28 +1645,15 @@ describe('Select.Basic', () => {
1657
1645
) ;
1658
1646
1659
1647
wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : 'i' } } ) ;
1660
- expect (
1661
- wrapper
1662
- . find ( '.rc-select-item-option-content' )
1663
- . first ( )
1664
- . text ( ) ,
1665
- ) . toBe ( 'Communicated' ) ;
1648
+ expect ( wrapper . find ( '.rc-select-item-option-content' ) . first ( ) . text ( ) ) . toBe ( 'Communicated' ) ;
1666
1649
} ) ;
1667
1650
1668
1651
it ( 'correctly handles the `tabIndex` prop' , ( ) => {
1669
1652
const wrapper = mount ( < Select tabIndex = { 0 } /> ) ;
1670
- expect (
1671
- wrapper
1672
- . find ( '.rc-select' )
1673
- . getDOMNode ( )
1674
- . getAttribute ( 'tabindex' ) ,
1675
- ) . toBeNull ( ) ;
1653
+ expect ( wrapper . find ( '.rc-select' ) . getDOMNode ( ) . getAttribute ( 'tabindex' ) ) . toBeNull ( ) ;
1676
1654
1677
1655
expect (
1678
- wrapper
1679
- . find ( 'input.rc-select-selection-search-input' )
1680
- . getDOMNode ( )
1681
- . getAttribute ( 'tabindex' ) ,
1656
+ wrapper . find ( 'input.rc-select-selection-search-input' ) . getDOMNode ( ) . getAttribute ( 'tabindex' ) ,
1682
1657
) . toBe ( '0' ) ;
1683
1658
} ) ;
1684
1659
} ) ;
0 commit comments