@@ -8,7 +8,7 @@ import KeyCode from '@rc-component/util/lib/KeyCode';
88import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook' ;
99import { resetWarned } from '@rc-component/util/lib/warning' ;
1010import React from 'react' ;
11- import { PickerPanel , type PickerRef } from '../src' ;
11+ import Picker , { PickerPanel , type PickerRef } from '../src' ;
1212import type { PanelMode , PickerMode } from '../src/interface' ;
1313import momentGenerateConfig from '../src/generate/moment' ;
1414import enUS from '../src/locale/en_US' ;
@@ -1406,6 +1406,62 @@ describe('Picker.Basic', () => {
14061406 expect ( item ) . toHaveClass ( customClassNames . popupItem ) ;
14071407 expect ( item ) . toHaveStyle ( customStyles . popupItem ) ;
14081408 } ) ;
1409+ it ( 'classNames and styles should support time panel' , async ( ) => {
1410+ const testClassNames = {
1411+ input : 'test-input' ,
1412+ prefix : 'test-prefix' ,
1413+ suffix : 'test-suffix' ,
1414+ popupContent : 'custom-content' ,
1415+ popupItem : 'custom-item' ,
1416+ } ;
1417+ const testStyles = {
1418+ input : { color : 'red' } ,
1419+ prefix : { color : 'green' } ,
1420+ suffix : { color : 'blue' } ,
1421+ popupContent : { color : 'blue' } ,
1422+ popupItem : { color : 'yellow' } ,
1423+ } ;
1424+ const defaultValue = moment ( '2019-11-28 01:02:03' ) ;
1425+ const { container } = render (
1426+ < Picker
1427+ classNames = { testClassNames }
1428+ styles = { testStyles }
1429+ prefix = "prefix"
1430+ suffixIcon = "suffix"
1431+ defaultValue = { defaultValue }
1432+ picker = "time"
1433+ locale = { zhCN }
1434+ disabledTime = { ( now ) => ( {
1435+ disabledHours : ( ) => [ now . hours ( ) ] ,
1436+ } ) }
1437+ generateConfig = { momentGenerateConfig }
1438+ /> ,
1439+ ) ;
1440+ const input = container . querySelectorAll ( '.rc-picker-input' ) [ 0 ] ;
1441+ const prefix = container . querySelector ( '.rc-picker-prefix' ) ;
1442+ const suffix = container . querySelector ( '.rc-picker-suffix' ) ;
1443+ expect ( input ) . toHaveClass ( testClassNames . input ) ;
1444+ expect ( input ) . toHaveStyle ( testStyles . input ) ;
1445+ expect ( prefix ) . toHaveClass ( testClassNames . prefix ) ;
1446+ expect ( prefix ) . toHaveStyle ( testStyles . prefix ) ;
1447+ expect ( suffix ) . toHaveClass ( testClassNames . suffix ) ;
1448+ expect ( suffix ) . toHaveStyle ( testStyles . suffix ) ;
1449+ const { container : panel } = render (
1450+ < PickerPanel
1451+ classNames = { testClassNames }
1452+ styles = { testStyles }
1453+ picker = "time"
1454+ locale = { enUS }
1455+ generateConfig = { momentGenerateConfig }
1456+ /> ,
1457+ ) ;
1458+ const content = panel . querySelector ( '.rc-picker-content' ) ;
1459+ 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 ) ;
1464+ } ) ;
14091465 it ( 'showTime config should have format' , ( ) => {
14101466 render (
14111467 < DayPicker
0 commit comments