@@ -1351,42 +1351,53 @@ describe('Picker.Basic', () => {
1351
1351
} ) ;
1352
1352
1353
1353
it ( 'support classNames and styles' , ( ) => {
1354
- const customClassNames = {
1355
- popup : 'custom-popup' ,
1356
- popupBody : 'custom-body' ,
1357
- popupContent : 'custom-content' ,
1358
- popupItem : 'custom-item' ,
1354
+ const popupClassNames = {
1355
+ root : 'custom-popup' ,
1356
+ body : 'custom-body' ,
1357
+ content : 'custom-content' ,
1358
+ item : 'custom-item' ,
1359
1359
} ;
1360
- const customStyles = {
1361
- popup : { color : 'red' } ,
1362
- popupBody : { color : 'green' } ,
1363
- popupContent : { color : 'blue' } ,
1364
- popupItem : { color : 'yellow' } ,
1360
+ const popupStyles = {
1361
+ root : { color : 'red' } ,
1362
+ body : { color : 'green' } ,
1363
+ content : { color : 'blue' } ,
1364
+ item : { color : 'yellow' } ,
1365
1365
} ;
1366
- render ( < DayPicker classNames = { customClassNames } styles = { customStyles } open /> ) ;
1366
+ render (
1367
+ < DayPicker
1368
+ classNames = { {
1369
+ popup : popupClassNames ,
1370
+ } }
1371
+ styles = { {
1372
+ popup : popupStyles ,
1373
+ } }
1374
+ open
1375
+ /> ,
1376
+ ) ;
1367
1377
1368
- expect ( document . querySelector ( '.rc-picker-dropdown' ) ) . toHaveClass ( customClassNames . popup ) ;
1369
- expect ( document . querySelector ( '.rc-picker-dropdown' ) ) . toHaveStyle ( customStyles . popup ) ;
1378
+ expect ( document . querySelector ( '.rc-picker-dropdown' ) ) . toHaveClass ( popupClassNames . root ) ;
1379
+ expect ( document . querySelector ( '.rc-picker-dropdown' ) ) . toHaveStyle ( popupStyles . root ) ;
1370
1380
const content = document . querySelector ( '.rc-picker-content' ) ;
1371
1381
const body = document . querySelector ( '.rc-picker-body' ) ;
1372
1382
const item = document . querySelector ( '.rc-picker-cell' ) ;
1373
- expect ( content ) . toHaveClass ( customClassNames . popupContent ) ;
1374
- expect ( content ) . toHaveStyle ( customStyles . popupContent ) ;
1375
- expect ( body ) . toHaveClass ( customClassNames . popupBody ) ;
1376
- expect ( body ) . toHaveStyle ( customStyles . popupBody ) ;
1377
- expect ( item ) . toHaveClass ( customClassNames . popupItem ) ;
1378
- expect ( item ) . toHaveStyle ( customStyles . popupItem ) ;
1383
+ expect ( content ) . toHaveClass ( popupClassNames . content ) ;
1384
+ expect ( content ) . toHaveStyle ( popupStyles . content ) ;
1385
+ expect ( body ) . toHaveClass ( popupClassNames . body ) ;
1386
+ expect ( body ) . toHaveStyle ( popupStyles . body ) ;
1387
+ expect ( item ) . toHaveClass ( popupClassNames . item ) ;
1388
+ expect ( item ) . toHaveStyle ( popupStyles . item ) ;
1379
1389
} ) ;
1390
+
1380
1391
it ( 'support classNames and styles for panel' , ( ) => {
1381
1392
const customClassNames = {
1382
- popupBody : 'custom-body' ,
1383
- popupContent : 'custom-content' ,
1384
- popupItem : 'custom-item' ,
1393
+ body : 'custom-body' ,
1394
+ content : 'custom-content' ,
1395
+ item : 'custom-item' ,
1385
1396
} ;
1386
1397
const customStyles = {
1387
- popupBody : { color : 'green' } ,
1388
- popupContent : { color : 'blue' } ,
1389
- popupItem : { color : 'yellow' } ,
1398
+ body : { color : 'green' } ,
1399
+ content : { color : 'blue' } ,
1400
+ item : { color : 'yellow' } ,
1390
1401
} ;
1391
1402
render (
1392
1403
< PickerPanel
@@ -1399,33 +1410,43 @@ describe('Picker.Basic', () => {
1399
1410
const content = document . querySelector ( '.rc-picker-content' ) ;
1400
1411
const body = document . querySelector ( '.rc-picker-body' ) ;
1401
1412
const item = document . querySelector ( '.rc-picker-cell' ) ;
1402
- expect ( content ) . toHaveClass ( customClassNames . popupContent ) ;
1403
- expect ( content ) . toHaveStyle ( customStyles . popupContent ) ;
1404
- expect ( body ) . toHaveClass ( customClassNames . popupBody ) ;
1405
- expect ( body ) . toHaveStyle ( customStyles . popupBody ) ;
1406
- expect ( item ) . toHaveClass ( customClassNames . popupItem ) ;
1407
- expect ( item ) . toHaveStyle ( customStyles . popupItem ) ;
1413
+ expect ( content ) . toHaveClass ( customClassNames . content ) ;
1414
+ expect ( content ) . toHaveStyle ( customStyles . content ) ;
1415
+ expect ( body ) . toHaveClass ( customClassNames . body ) ;
1416
+ expect ( body ) . toHaveStyle ( customStyles . body ) ;
1417
+ expect ( item ) . toHaveClass ( customClassNames . item ) ;
1418
+ expect ( item ) . toHaveStyle ( customStyles . item ) ;
1408
1419
} ) ;
1420
+
1409
1421
it ( 'classNames and styles should support time panel' , async ( ) => {
1410
1422
const testClassNames = {
1411
1423
input : 'test-input' ,
1412
1424
prefix : 'test-prefix' ,
1413
1425
suffix : 'test-suffix' ,
1414
- popupContent : 'custom-content' ,
1415
- popupItem : 'custom-item' ,
1416
1426
} ;
1427
+ const testPopupClassNames = {
1428
+ content : 'test-popup-content' ,
1429
+ item : 'test-popup-item' ,
1430
+ } ;
1431
+
1417
1432
const testStyles = {
1418
1433
input : { color : 'red' } ,
1419
1434
prefix : { color : 'green' } ,
1420
1435
suffix : { color : 'blue' } ,
1421
- popupContent : { color : 'blue' } ,
1422
- popupItem : { color : 'yellow' } ,
1423
1436
} ;
1437
+ const testPopupStyles = {
1438
+ content : { color : 'blue' } ,
1439
+ item : { color : 'yellow' } ,
1440
+ } ;
1441
+
1424
1442
const defaultValue = moment ( '2019-11-28 01:02:03' ) ;
1425
1443
const { container } = render (
1426
1444
< Picker
1427
- classNames = { testClassNames }
1428
- styles = { testStyles }
1445
+ classNames = { { ...testClassNames , popup : testPopupClassNames } }
1446
+ styles = { {
1447
+ ...testStyles ,
1448
+ popup : testPopupStyles ,
1449
+ } }
1429
1450
prefix = "prefix"
1430
1451
suffixIcon = "suffix"
1431
1452
defaultValue = { defaultValue }
@@ -1437,7 +1458,7 @@ describe('Picker.Basic', () => {
1437
1458
generateConfig = { momentGenerateConfig }
1438
1459
/> ,
1439
1460
) ;
1440
- const input = container . querySelectorAll ( '.rc-picker-input' ) [ 0 ] ;
1461
+ const input = container . querySelectorAll ( '.rc-picker-input input ' ) [ 0 ] ;
1441
1462
const prefix = container . querySelector ( '.rc-picker-prefix' ) ;
1442
1463
const suffix = container . querySelector ( '.rc-picker-suffix' ) ;
1443
1464
expect ( input ) . toHaveClass ( testClassNames . input ) ;
@@ -1448,20 +1469,21 @@ describe('Picker.Basic', () => {
1448
1469
expect ( suffix ) . toHaveStyle ( testStyles . suffix ) ;
1449
1470
const { container : panel } = render (
1450
1471
< PickerPanel
1451
- classNames = { testClassNames }
1452
- styles = { testStyles }
1472
+ classNames = { testPopupClassNames }
1473
+ styles = { testPopupStyles }
1453
1474
picker = "time"
1454
1475
locale = { enUS }
1455
1476
generateConfig = { momentGenerateConfig }
1456
1477
/> ,
1457
1478
) ;
1458
1479
const content = panel . querySelector ( '.rc-picker-content' ) ;
1459
1480
const item = panel . querySelector ( '.rc-picker-time-panel-cell' ) ;
1460
- expect ( content ) . toHaveClass ( testClassNames . popupContent ) ;
1461
- expect ( content ) . toHaveStyle ( testStyles . popupContent ) ;
1462
- expect ( item ) . toHaveClass ( testClassNames . popupItem ) ;
1463
- expect ( item ) . toHaveStyle ( testStyles . popupItem ) ;
1481
+ expect ( content ) . toHaveClass ( testPopupClassNames . content ) ;
1482
+ expect ( content ) . toHaveStyle ( testPopupStyles . content ) ;
1483
+ expect ( item ) . toHaveClass ( testPopupClassNames . item ) ;
1484
+ expect ( item ) . toHaveStyle ( testPopupStyles . item ) ;
1464
1485
} ) ;
1486
+
1465
1487
it ( 'showTime config should have format' , ( ) => {
1466
1488
render (
1467
1489
< DayPicker
0 commit comments