@@ -1417,17 +1417,55 @@ describe('Select.Basic', () => {
1417
1417
expect ( onKeyUp ) . toHaveBeenCalled ( ) ;
1418
1418
} ) ;
1419
1419
1420
- it ( 'warning if label not same as option' , ( ) => {
1421
- const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
1422
- mount (
1423
- < Select value = { { value : '2' , label : 'One' } } labelInValue >
1424
- < Option value = "2" > Two</ Option >
1425
- </ Select > ,
1426
- ) ;
1427
- expect ( errorSpy ) . toHaveBeenCalledWith (
1428
- 'Warning: `label` of `value` is not same as `label` in Select options.' ,
1429
- ) ;
1430
- errorSpy . mockRestore ( ) ;
1420
+ describe ( 'warning if label not same as option' , ( ) => {
1421
+ it ( 'should work' , ( ) => {
1422
+ resetWarned ( ) ;
1423
+
1424
+ const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
1425
+ mount (
1426
+ < Select value = { { value : '2' , label : 'One' } } labelInValue >
1427
+ < Option value = "2" > Two</ Option >
1428
+ </ Select > ,
1429
+ ) ;
1430
+ expect ( errorSpy ) . toHaveBeenCalledWith (
1431
+ 'Warning: `label` of `value` is not same as `label` in Select options.' ,
1432
+ ) ;
1433
+ errorSpy . mockRestore ( ) ;
1434
+ } ) ;
1435
+
1436
+ it ( 'not warning for react node' , ( ) => {
1437
+ resetWarned ( ) ;
1438
+ const errorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
1439
+
1440
+ const Demo = ( ) => {
1441
+ const [ , setVal ] = React . useState ( 0 ) ;
1442
+
1443
+ return (
1444
+ < Select
1445
+ onChange = { setVal }
1446
+ defaultValue = { 0 }
1447
+ options = { [
1448
+ {
1449
+ value : 0 ,
1450
+ label : < div /> ,
1451
+ } ,
1452
+ {
1453
+ value : 1 ,
1454
+ label : < div /> ,
1455
+ } ,
1456
+ ] }
1457
+ />
1458
+ ) ;
1459
+ } ;
1460
+
1461
+ const wrapper = mount ( < Demo /> ) ;
1462
+
1463
+ toggleOpen ( wrapper ) ;
1464
+ selectItem ( wrapper , 1 ) ;
1465
+
1466
+ expect ( errorSpy ) . not . toHaveBeenCalled ( ) ;
1467
+ errorSpy . mockRestore ( ) ;
1468
+ } ) ;
1431
1469
} ) ;
1432
1470
1433
1471
describe ( 'warning if use `props` to read data' , ( ) => {
0 commit comments