@@ -41,6 +41,10 @@ describe('Notification.Basic', () => {
4141 }
4242 }
4343
44+ function expectContentStyle ( selector : string , content : string ) {
45+ expect ( ( document . querySelector ( selector ) as HTMLElement ) . style . content ) . toBe ( `"${ content } "` ) ;
46+ }
47+
4448 it ( 'works' , ( ) => {
4549 const { instance, unmount } = renderDemo ( ) ;
4650
@@ -637,17 +641,15 @@ describe('Notification.Basic', () => {
637641 it ( 'should style work' , ( ) => {
638642 const { instance } = renderDemo ( {
639643 style : ( ) => ( {
640- content : 'little' ,
644+ content : '" little" ' ,
641645 } ) ,
642646 } ) ;
643647
644648 act ( ( ) => {
645649 instance . open ( { } ) ;
646650 } ) ;
647651
648- expect ( document . querySelector ( '.rc-notification' ) ) . toHaveStyle ( {
649- content : 'little' ,
650- } ) ;
652+ expectContentStyle ( '.rc-notification' , 'little' ) ;
651653 } ) ;
652654
653655 it ( 'should open style and className work' , ( ) => {
@@ -656,15 +658,13 @@ describe('Notification.Basic', () => {
656658 act ( ( ) => {
657659 instance . open ( {
658660 style : {
659- content : 'little' ,
661+ content : '" little" ' ,
660662 } ,
661663 className : 'bamboo' ,
662664 } ) ;
663665 } ) ;
664666
665- expect ( document . querySelector ( '.rc-notification-notice' ) ) . toHaveStyle ( {
666- content : 'little' ,
667- } ) ;
667+ expectContentStyle ( '.rc-notification-notice' , 'little' ) ;
668668 expect ( document . querySelector ( '.rc-notification-notice' ) ) . toHaveClass ( 'bamboo' ) ;
669669 } ) ;
670670
@@ -706,7 +706,7 @@ describe('Notification.Basic', () => {
706706 description : 'little' ,
707707 styles : {
708708 section : {
709- content : 'light' ,
709+ content : '" light" ' ,
710710 } ,
711711 } ,
712712 classNames : {
@@ -715,9 +715,7 @@ describe('Notification.Basic', () => {
715715 } ) ;
716716 } ) ;
717717
718- expect ( document . querySelector ( '.rc-notification-notice-section' ) ) . toHaveStyle ( {
719- content : 'light' ,
720- } ) ;
718+ expectContentStyle ( '.rc-notification-notice-section' , 'light' ) ;
721719 expect ( document . querySelector ( '.rc-notification-notice-section' ) ) . toHaveClass ( 'section-class' ) ;
722720 } ) ;
723721
@@ -729,7 +727,7 @@ describe('Notification.Basic', () => {
729727 icon : < span /> ,
730728 styles : {
731729 wrapper : {
732- content : 'little' ,
730+ content : '" little" ' ,
733731 } ,
734732 } ,
735733 classNames : {
@@ -738,9 +736,7 @@ describe('Notification.Basic', () => {
738736 } ) ;
739737 } ) ;
740738
741- expect ( document . querySelector ( '.rc-notification-notice-wrapper' ) ) . toHaveStyle ( {
742- content : 'little' ,
743- } ) ;
739+ expectContentStyle ( '.rc-notification-notice-wrapper' , 'little' ) ;
744740 expect ( document . querySelector ( '.rc-notification-notice-wrapper' ) ) . toHaveClass ( 'bamboo' ) ;
745741 } ) ;
746742
@@ -777,16 +773,16 @@ describe('Notification.Basic', () => {
777773 } ,
778774 styles : {
779775 title : {
780- content : 'global-title' ,
776+ content : '" global-title" ' ,
781777 } ,
782778 description : {
783- content : 'global-description' ,
779+ content : '" global-description" ' ,
784780 } ,
785781 actions : {
786- content : 'global-actions' ,
782+ content : '" global-actions" ' ,
787783 } ,
788784 icon : {
789- content : 'global-icon' ,
785+ content : '" global-icon" ' ,
790786 } ,
791787 } ,
792788 } ) ;
@@ -824,33 +820,33 @@ describe('Notification.Basic', () => {
824820 'global-title' ,
825821 'notice-title' ,
826822 ) ;
823+ expectContentStyle ( '.rc-notification-notice-title' , 'global-title' ) ;
827824 expect ( document . querySelector ( '.rc-notification-notice-title' ) ) . toHaveStyle ( {
828- content : 'global-title' ,
829825 marginTop : '1px' ,
830826 } ) ;
831827 expect ( document . querySelector ( '.rc-notification-notice-description' ) ) . toHaveClass (
832828 'global-description' ,
833829 'notice-description' ,
834830 ) ;
831+ expectContentStyle ( '.rc-notification-notice-description' , 'global-description' ) ;
835832 expect ( document . querySelector ( '.rc-notification-notice-description' ) ) . toHaveStyle ( {
836- content : 'global-description' ,
837833 marginRight : '2px' ,
838834 } ) ;
839835 expect ( document . querySelector ( '.rc-notification-notice-actions' ) ) . toHaveClass (
840836 'global-actions' ,
841837 'notice-actions' ,
842838 ) ;
839+ expectContentStyle ( '.rc-notification-notice-actions' , 'global-actions' ) ;
843840 expect ( document . querySelector ( '.rc-notification-notice-actions' ) ) . toHaveStyle ( {
844- content : 'global-actions' ,
845841 marginBottom : '3px' ,
846842 } ) ;
847843 expect ( document . querySelector ( '.actions' ) ) . toBeFalsy ( ) ;
848844 expect ( document . querySelector ( '.rc-notification-notice-icon' ) ) . toHaveClass (
849845 'global-icon' ,
850846 'notice-icon' ,
851847 ) ;
848+ expectContentStyle ( '.rc-notification-notice-icon' , 'global-icon' ) ;
852849 expect ( document . querySelector ( '.rc-notification-notice-icon' ) ) . toHaveStyle ( {
853- content : 'global-icon' ,
854850 marginLeft : '4px' ,
855851 } ) ;
856852 } ) ;
@@ -875,10 +871,10 @@ describe('Notification.Basic', () => {
875871 } ,
876872 styles : {
877873 list : {
878- content : 'root-list' ,
874+ content : '" root-list" ' ,
879875 } ,
880876 listContent : {
881- content : 'little' ,
877+ content : '" little" ' ,
882878 } ,
883879 } ,
884880 } ) ;
@@ -887,13 +883,9 @@ describe('Notification.Basic', () => {
887883 instance . open ( { } ) ;
888884 } ) ;
889885
890- expect ( document . querySelector ( '.rc-notification-list' ) ) . toHaveStyle ( {
891- content : 'root-list' ,
892- } ) ;
886+ expectContentStyle ( '.rc-notification-list' , 'root-list' ) ;
893887 expect ( document . querySelector ( '.rc-notification-list' ) ) . toHaveClass ( 'root-list' ) ;
894- expect ( document . querySelector ( '.rc-notification-list-content' ) ) . toHaveStyle ( {
895- content : 'little' ,
896- } ) ;
888+ expectContentStyle ( '.rc-notification-list-content' , 'little' ) ;
897889 expect ( document . querySelector ( '.rc-notification-list-content' ) ) . toHaveClass ( 'bamboo' ) ;
898890 } ) ;
899891
0 commit comments