@@ -1351,42 +1351,53 @@ describe('Picker.Basic', () => {
13511351 } ) ;
13521352
13531353 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' ,
13591359 } ;
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' } ,
13651365 } ;
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+ ) ;
13671377
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 ) ;
13701380 const content = document . querySelector ( '.rc-picker-content' ) ;
13711381 const body = document . querySelector ( '.rc-picker-body' ) ;
13721382 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 ) ;
13791389 } ) ;
1390+
13801391 it ( 'support classNames and styles for panel' , ( ) => {
13811392 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' ,
13851396 } ;
13861397 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' } ,
13901401 } ;
13911402 render (
13921403 < PickerPanel
@@ -1399,33 +1410,43 @@ describe('Picker.Basic', () => {
13991410 const content = document . querySelector ( '.rc-picker-content' ) ;
14001411 const body = document . querySelector ( '.rc-picker-body' ) ;
14011412 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 ) ;
14081419 } ) ;
1420+
14091421 it ( 'classNames and styles should support time panel' , async ( ) => {
14101422 const testClassNames = {
14111423 input : 'test-input' ,
14121424 prefix : 'test-prefix' ,
14131425 suffix : 'test-suffix' ,
1414- popupContent : 'custom-content' ,
1415- popupItem : 'custom-item' ,
14161426 } ;
1427+ const testPopupClassNames = {
1428+ content : 'test-popup-content' ,
1429+ item : 'test-popup-item' ,
1430+ } ;
1431+
14171432 const testStyles = {
14181433 input : { color : 'red' } ,
14191434 prefix : { color : 'green' } ,
14201435 suffix : { color : 'blue' } ,
1421- popupContent : { color : 'blue' } ,
1422- popupItem : { color : 'yellow' } ,
14231436 } ;
1437+ const testPopupStyles = {
1438+ content : { color : 'blue' } ,
1439+ item : { color : 'yellow' } ,
1440+ } ;
1441+
14241442 const defaultValue = moment ( '2019-11-28 01:02:03' ) ;
14251443 const { container } = render (
14261444 < Picker
1427- classNames = { testClassNames }
1428- styles = { testStyles }
1445+ classNames = { { ...testClassNames , popup : testPopupClassNames } }
1446+ styles = { {
1447+ ...testStyles ,
1448+ popup : testPopupStyles ,
1449+ } }
14291450 prefix = "prefix"
14301451 suffixIcon = "suffix"
14311452 defaultValue = { defaultValue }
@@ -1437,7 +1458,7 @@ describe('Picker.Basic', () => {
14371458 generateConfig = { momentGenerateConfig }
14381459 /> ,
14391460 ) ;
1440- const input = container . querySelectorAll ( '.rc-picker-input' ) [ 0 ] ;
1461+ const input = container . querySelectorAll ( '.rc-picker-input input ' ) [ 0 ] ;
14411462 const prefix = container . querySelector ( '.rc-picker-prefix' ) ;
14421463 const suffix = container . querySelector ( '.rc-picker-suffix' ) ;
14431464 expect ( input ) . toHaveClass ( testClassNames . input ) ;
@@ -1448,20 +1469,21 @@ describe('Picker.Basic', () => {
14481469 expect ( suffix ) . toHaveStyle ( testStyles . suffix ) ;
14491470 const { container : panel } = render (
14501471 < PickerPanel
1451- classNames = { testClassNames }
1452- styles = { testStyles }
1472+ classNames = { testPopupClassNames }
1473+ styles = { testPopupStyles }
14531474 picker = "time"
14541475 locale = { enUS }
14551476 generateConfig = { momentGenerateConfig }
14561477 /> ,
14571478 ) ;
14581479 const content = panel . querySelector ( '.rc-picker-content' ) ;
14591480 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 ) ;
14641485 } ) ;
1486+
14651487 it ( 'showTime config should have format' , ( ) => {
14661488 render (
14671489 < DayPicker
0 commit comments