@@ -584,6 +584,46 @@ describe('Notification.Basic', () => {
584584 expect ( notice [ 0 ] . getAttribute ( 'role' ) ) . toBe ( 'alert' ) ;
585585 } ) ;
586586
587+ it ( 'sets role attribute from notification config' , ( ) => {
588+ const { instance } = renderDemo ( ) ;
589+
590+ act ( ( ) => {
591+ instance . open ( {
592+ title : 'bamboo' ,
593+ description : < span className = "test-role-description" > simple show</ span > ,
594+ icon : < span className = "test-role-icon" /> ,
595+ actions : < button type = "button" > light</ button > ,
596+ role : 'status' ,
597+ closable : true ,
598+ showProgress : true ,
599+ duration : 3 ,
600+ } ) ;
601+ } ) ;
602+
603+ const notice = document . querySelector ( '.rc-notification-notice' ) ;
604+
605+ expect ( notice ) . toHaveAttribute ( 'role' , 'status' ) ;
606+ expect ( notice . querySelector ( '.rc-notification-notice-content' ) ) . toBeFalsy ( ) ;
607+ expect ( notice . querySelector ( '.rc-notification-notice-title' ) ) . toBeTruthy ( ) ;
608+ expect ( notice . querySelector ( '.rc-notification-notice-description' ) ) . toBeTruthy ( ) ;
609+ expect ( notice . querySelector ( '.rc-notification-notice-icon' ) ) . toBeTruthy ( ) ;
610+ expect ( notice . querySelector ( '.rc-notification-notice-actions' ) ) . toBeTruthy ( ) ;
611+ expect ( notice . querySelector ( '.rc-notification-notice-close' ) ) . toBeTruthy ( ) ;
612+ expect ( notice . querySelector ( '.rc-notification-notice-progress' ) ) . toBeTruthy ( ) ;
613+ } ) ;
614+
615+ it ( 'sets default role attribute' , ( ) => {
616+ const { instance } = renderDemo ( ) ;
617+
618+ act ( ( ) => {
619+ instance . open ( {
620+ description : < span className = "test-default-role" > simple show</ span > ,
621+ } ) ;
622+ } ) ;
623+
624+ expect ( document . querySelector ( '.rc-notification-notice' ) ) . toHaveAttribute ( 'role' , 'alert' ) ;
625+ } ) ;
626+
587627 it ( 'should style work' , ( ) => {
588628 const { instance } = renderDemo ( {
589629 style : ( ) => ( {
@@ -694,6 +734,94 @@ describe('Notification.Basic', () => {
694734 expect ( document . querySelector ( '.bamboo' ) ) . toHaveClass ( 'bamboo' ) ;
695735 } ) ;
696736
737+ it ( 'should support semantic content styles and classNames' , ( ) => {
738+ const { instance } = renderDemo ( {
739+ classNames : {
740+ title : 'global-title' ,
741+ description : 'global-description' ,
742+ actions : 'global-actions' ,
743+ icon : 'global-icon' ,
744+ } ,
745+ styles : {
746+ title : {
747+ content : 'global-title' ,
748+ } ,
749+ description : {
750+ content : 'global-description' ,
751+ } ,
752+ actions : {
753+ content : 'global-actions' ,
754+ } ,
755+ icon : {
756+ content : 'global-icon' ,
757+ } ,
758+ } ,
759+ } ) ;
760+
761+ act ( ( ) => {
762+ instance . open ( {
763+ title : 'bamboo' ,
764+ description : 'little' ,
765+ icon : < span /> ,
766+ actions : < button type = "button" > light</ button > ,
767+ classNames : {
768+ title : 'notice-title' ,
769+ description : 'notice-description' ,
770+ actions : 'notice-actions' ,
771+ icon : 'notice-icon' ,
772+ } ,
773+ styles : {
774+ title : {
775+ marginTop : 1 ,
776+ } ,
777+ description : {
778+ marginRight : 2 ,
779+ } ,
780+ actions : {
781+ marginBottom : 3 ,
782+ } ,
783+ icon : {
784+ marginLeft : 4 ,
785+ } ,
786+ } ,
787+ } ) ;
788+ } ) ;
789+
790+ expect ( document . querySelector ( '.rc-notification-notice-title' ) ) . toHaveClass (
791+ 'global-title' ,
792+ 'notice-title' ,
793+ ) ;
794+ expect ( document . querySelector ( '.rc-notification-notice-title' ) ) . toHaveStyle ( {
795+ content : 'global-title' ,
796+ marginTop : '1px' ,
797+ } ) ;
798+ expect ( document . querySelector ( '.rc-notification-notice-description' ) ) . toHaveClass (
799+ 'global-description' ,
800+ 'notice-description' ,
801+ ) ;
802+ expect ( document . querySelector ( '.rc-notification-notice-description' ) ) . toHaveStyle ( {
803+ content : 'global-description' ,
804+ marginRight : '2px' ,
805+ } ) ;
806+ expect ( document . querySelector ( '.rc-notification-notice-actions' ) ) . toHaveClass (
807+ 'global-actions' ,
808+ 'notice-actions' ,
809+ ) ;
810+ expect ( document . querySelector ( '.rc-notification-notice-actions' ) ) . toHaveStyle ( {
811+ content : 'global-actions' ,
812+ marginBottom : '3px' ,
813+ } ) ;
814+ expect ( document . querySelector ( '.actions' ) ) . toBeFalsy ( ) ;
815+ expect ( document . querySelector ( '.rc-notification-notice-icon' ) ) . toHaveClass (
816+ 'global-icon' ,
817+ 'notice-icon' ,
818+ ) ;
819+ expect ( document . querySelector ( '.rc-notification-notice-icon' ) ) . toHaveStyle ( {
820+ content : 'global-icon' ,
821+ marginLeft : '4px' ,
822+ } ) ;
823+ } ) ;
824+
697825 it ( 'should className work' , ( ) => {
698826 const { instance } = renderDemo ( {
699827 className : ( placement ) => `bamboo-${ placement } ` ,
0 commit comments