@@ -1034,33 +1034,31 @@ describe('ReactDOMComponent', () => {
1034
1034
return ( str + '' ) . replace ( / ( [ . ? * + \^ $ \[ \] \\ ( ) { } | - ] ) / g, '\\$1' ) ;
1035
1035
}
1036
1036
1037
- function toHaveAttribute ( actual , expected ) {
1037
+ function expectToHaveAttribute ( actual , expected ) {
1038
1038
const [ attr , value ] = expected ;
1039
1039
let re = '(?:^|\\s)' + attr + '=[\\\'"]' ;
1040
1040
if ( typeof value !== 'undefined' ) {
1041
1041
re += quoteRegexp ( value ) + '[\\\'"]' ;
1042
1042
}
1043
- return new RegExp ( re ) . test ( actual ) ;
1043
+ expect ( new RegExp ( re ) . test ( actual ) ) . toBe ( true ) ;
1044
1044
}
1045
1045
1046
1046
function genMarkup ( props ) {
1047
1047
return ReactDOMServer . renderToString ( < div { ...props } /> ) ;
1048
1048
}
1049
1049
1050
1050
it ( 'should generate the correct markup with className' , ( ) => {
1051
- expect ( toHaveAttribute ( genMarkup ( { className : 'a' } ) , [ 'class' , 'a' ] ) ) ;
1052
- expect ( toHaveAttribute ( genMarkup ( { className : 'a b' } ) , [ 'class' , 'a b' ] ) ) ;
1053
- expect ( toHaveAttribute ( genMarkup ( { className : '' } ) , [ 'class' , '' ] ) ) ;
1051
+ expectToHaveAttribute ( genMarkup ( { className : 'a' } ) , [ 'class' , 'a' ] ) ;
1052
+ expectToHaveAttribute ( genMarkup ( { className : 'a b' } ) , [ 'class' , 'a b' ] ) ;
1053
+ expectToHaveAttribute ( genMarkup ( { className : '' } ) , [ 'class' , '' ] ) ;
1054
1054
} ) ;
1055
1055
1056
1056
it ( 'should escape style names and values' , ( ) => {
1057
- expect (
1058
- toHaveAttribute (
1059
- genMarkup ( {
1060
- style : { 'b&ckground' : '<3' } ,
1061
- } ) ,
1062
- [ 'style' , 'b&ckground:<3;' ] ,
1063
- ) ,
1057
+ expectToHaveAttribute (
1058
+ genMarkup ( {
1059
+ style : { 'b&ckground' : '<3' } ,
1060
+ } ) ,
1061
+ [ 'style' , 'b&ckground:<3' ] ,
1064
1062
) ;
1065
1063
} ) ;
1066
1064
} ) ;
@@ -1075,7 +1073,7 @@ describe('ReactDOMComponent', () => {
1075
1073
}
1076
1074
1077
1075
function toHaveInnerhtml ( actual , expected ) {
1078
- const re = '^' + quoteRegexp ( expected ) + '$' ;
1076
+ const re = quoteRegexp ( expected ) ;
1079
1077
return new RegExp ( re ) . test ( actual ) ;
1080
1078
}
1081
1079
@@ -1086,7 +1084,7 @@ describe('ReactDOMComponent', () => {
1086
1084
genMarkup ( { dangerouslySetInnerHTML : innerHTML } ) ,
1087
1085
'testContent' ,
1088
1086
) ,
1089
- ) ;
1087
+ ) . toBe ( true ) ;
1090
1088
} ) ;
1091
1089
} ) ;
1092
1090
0 commit comments