@@ -898,5 +898,59 @@ describe('collapse', () => {
898898 expect ( titleElement . style . color ) . toBe ( 'green' ) ;
899899 expect ( iconElement . style . color ) . toBe ( 'yellow' ) ;
900900 } ) ;
901+
902+ it ( 'should support styles and classNames in panel' , ( ) => {
903+ const customStyles = {
904+ header : { color : 'red' } ,
905+ body : { color : 'blue' } ,
906+ title : { color : 'green' } ,
907+ icon : { color : 'yellow' } ,
908+ } ;
909+ const customClassnames = {
910+ header : 'custom-header' ,
911+ body : 'custom-body' ,
912+ } ;
913+
914+ const { container } = render (
915+ < Collapse
916+ activeKey = { [ '1' ] }
917+ styles = { customStyles }
918+ classNames = { customClassnames }
919+ items = { [
920+ {
921+ key : '1' ,
922+ styles : {
923+ header : {
924+ color : 'blue' ,
925+ fontSize : 20 ,
926+ } ,
927+ body : {
928+ fontSize : 20 ,
929+ } ,
930+ } ,
931+ classNames : {
932+ header : 'custom-header-panel' ,
933+ body : 'custom-body-panel' ,
934+ } ,
935+ label : 'title' ,
936+ } ,
937+ ] }
938+ /> ,
939+ ) ;
940+ const headerElement = container . querySelector ( '.rc-collapse-header' ) as HTMLElement ;
941+ const bodyElement = container . querySelector ( '.rc-collapse-body' ) as HTMLElement ;
942+
943+ // check classNames
944+ expect ( headerElement . classList ) . toContain ( 'custom-header' ) ;
945+ expect ( headerElement . classList ) . toContain ( 'custom-header-panel' ) ;
946+ expect ( bodyElement . classList ) . toContain ( 'custom-body' ) ;
947+ expect ( bodyElement . classList ) . toContain ( 'custom-body-panel' ) ;
948+
949+ // check styles
950+ expect ( headerElement . style . color ) . toBe ( 'blue' ) ;
951+ expect ( headerElement . style . fontSize ) . toBe ( '20px' ) ;
952+ expect ( bodyElement . style . color ) . toBe ( 'blue' ) ;
953+ expect ( bodyElement . style . fontSize ) . toBe ( '20px' ) ;
954+ } ) ;
901955 } ) ;
902956} ) ;
0 commit comments