@@ -11,7 +11,7 @@ import {
1111 defaultHTMLElementModels ,
1212 HTMLContentModel
1313} from '@native-html/transient-render-engine' ;
14- import { Image , StyleSheet , Text } from 'react-native' ;
14+ import { Image , Text } from 'react-native' ;
1515import { useRendererProps } from '../context/RenderersPropsProvider' ;
1616import TNodeChildrenRenderer from '../TNodeChildrenRenderer' ;
1717import OLElement from '../elements/OLElement' ;
@@ -73,15 +73,16 @@ describe('RenderHTML', () => {
7373 contentWidth = { contentWidth }
7474 />
7575 ) ;
76- expect ( UNSAFE_getByType ( ImgTag ) . props . contentWidth ) . toBe ( contentWidth ) ;
76+ expect ( UNSAFE_getByType ( ImgTag ) ) . toHaveProp ( 'contentWidth' , contentWidth ) ;
7777 update (
7878 < RenderHTML
7979 source = { { html : '<img src="https://img.com/1" />' } }
8080 debug = { false }
8181 contentWidth = { nextContentWidth }
8282 />
8383 ) ;
84- expect ( UNSAFE_getByType ( ImgTag ) . props . contentWidth ) . toBe (
84+ expect ( UNSAFE_getByType ( ImgTag ) ) . toHaveProp (
85+ 'contentWidth' ,
8586 nextContentWidth
8687 ) ;
8788 } ) ;
@@ -101,8 +102,7 @@ describe('RenderHTML', () => {
101102 contentWidth = { 200 }
102103 />
103104 ) ;
104- const imgProps = getByA11yRole ( 'image' ) . props ;
105- expect ( StyleSheet . flatten ( imgProps . style ) ) . toMatchObject ( {
105+ expect ( getByA11yRole ( 'image' ) ) . toHaveStyle ( {
106106 backgroundColor : 'red'
107107 } ) ;
108108 } ) ;
@@ -201,7 +201,7 @@ describe('RenderHTML', () => {
201201 />
202202 ) ;
203203 const span = getByTestId ( 'span' ) ;
204- expect ( StyleSheet . flatten ( span . props . style ) ) . toMatchObject ( tagsStyles . span ) ;
204+ expect ( span ) . toHaveStyle ( tagsStyles . span ) ;
205205 } ) ;
206206 describe ( 'regarding onTTreeChange prop' , ( ) => {
207207 const onTTreeChange = jest . fn ( ) ;
@@ -398,7 +398,7 @@ describe('RenderHTML', () => {
398398 />
399399 ) ;
400400 const div = getByTestId ( 'div' ) ;
401- expect ( div . props . collapsable ) . toBe ( false ) ;
401+ expect ( div ) . toHaveProp ( 'collapsable' , false ) ;
402402 } ) ;
403403 it ( 'should apply `textProps` to TPhrasing renderers' , ( ) => {
404404 const SpanRenderer : CustomTextualRenderer = ( {
@@ -421,7 +421,7 @@ describe('RenderHTML', () => {
421421 />
422422 ) ;
423423 const span = getByTestId ( 'span' ) ;
424- expect ( span . props . adjustsFontSizeToFit ) . toBe ( true ) ;
424+ expect ( span ) . toHaveProp ( 'adjustsFontSizeToFit' , true ) ;
425425 } ) ;
426426 it ( 'should apply `textProps` to TText renderers' , ( ) => {
427427 const SpanRenderer : CustomTextualRenderer = ( {
@@ -444,7 +444,7 @@ describe('RenderHTML', () => {
444444 />
445445 ) ;
446446 const span = getByTestId ( 'span' ) ;
447- expect ( span . props . adjustsFontSizeToFit ) . toBe ( true ) ;
447+ expect ( span ) . toHaveProp ( 'adjustsFontSizeToFit' , true ) ;
448448 } ) ;
449449 it ( 'should apply `props`' , ( ) => {
450450 const SpanRenderer : CustomTextualRenderer = ( {
@@ -467,7 +467,7 @@ describe('RenderHTML', () => {
467467 />
468468 ) ;
469469 const span = getByTestId ( 'span' ) ;
470- expect ( span . props . accessibilityRole ) . toBe ( 'adjustable' ) ;
470+ expect ( span ) . toHaveProp ( 'accessibilityRole' , 'adjustable' ) ;
471471 } ) ;
472472 it ( 'should apply `tnode.getReactNativeProps()` to TPhrasing renderers' , ( ) => {
473473 const customHTMLElementModels : HTMLElementModelRecord = {
@@ -490,7 +490,7 @@ describe('RenderHTML', () => {
490490 />
491491 ) ;
492492 const span = getByTestId ( 'span' ) ;
493- expect ( span . props . accessibilityRole ) . toBe ( 'adjustable' ) ;
493+ expect ( span ) . toHaveProp ( 'accessibilityRole' , 'adjustable' ) ;
494494 } ) ;
495495 it ( 'should apply `tnode.getReactNativeProps()` to TText renderers' , ( ) => {
496496 const customHTMLElementModels : HTMLElementModelRecord = {
@@ -513,7 +513,7 @@ describe('RenderHTML', () => {
513513 />
514514 ) ;
515515 const span = getByTestId ( 'span' ) ;
516- expect ( span . props . accessibilityRole ) . toBe ( 'adjustable' ) ;
516+ expect ( span ) . toHaveProp ( 'accessibilityRole' , 'adjustable' ) ;
517517 } ) ;
518518 it ( 'should apply `tnode.getReactNativeProps()` to TBlock renderers' , ( ) => {
519519 const customHTMLElementModels : HTMLElementModelRecord = {
@@ -536,7 +536,7 @@ describe('RenderHTML', () => {
536536 />
537537 ) ;
538538 const div = getByTestId ( 'div' ) ;
539- expect ( div . props . accessibilityRole ) . toBe ( 'adjustable' ) ;
539+ expect ( div ) . toHaveProp ( 'accessibilityRole' , 'adjustable' ) ;
540540 } ) ;
541541 } ) ;
542542 describe ( 'regarding TNodeRenderer' , ( ) => {
@@ -580,7 +580,7 @@ describe('RenderHTML', () => {
580580 />
581581 ) ;
582582 const div = await findByTestId ( 'div' ) ;
583- expect ( StyleSheet . flatten ( div . props . style ) ) . toEqual ( {
583+ expect ( div ) . toHaveStyle ( {
584584 marginBottom : 10 ,
585585 paddingBottom : 10
586586 } ) ;
@@ -606,7 +606,7 @@ describe('RenderHTML', () => {
606606 />
607607 ) ;
608608 const div = await findByTestId ( 'div' ) ;
609- expect ( StyleSheet . flatten ( div . props . style ) ) . toEqual ( {
609+ expect ( div ) . toHaveStyle ( {
610610 marginBottom : 10
611611 } ) ;
612612 } ) ;
@@ -632,7 +632,7 @@ describe('RenderHTML', () => {
632632 />
633633 ) ;
634634 const div = await findByTestId ( 'span' ) ;
635- expect ( StyleSheet . flatten ( div . props . style ) ) . toMatchObject ( {
635+ expect ( div ) . toHaveStyle ( {
636636 marginBottom : 10
637637 } ) ;
638638 } ) ;
@@ -651,10 +651,10 @@ describe('RenderHTML', () => {
651651 enableExperimentalMarginCollapsing
652652 />
653653 ) ;
654- const div = getByTestId ( 'div' ) ;
655- const p = getByTestId ( 'p' ) ;
656- expect ( StyleSheet . flatten ( div . props . style ) . marginBottom ) . toBe ( 10 ) ;
657- expect ( StyleSheet . flatten ( p . props . style ) . marginTop ) . toBe ( 0 ) ;
654+ expect ( getByTestId ( 'div' ) ) . toHaveStyle ( {
655+ marginBottom : 10
656+ } ) ;
657+ expect ( getByTestId ( 'p' ) ) . toHaveStyle ( { marginTop : 0 } ) ;
658658 } ) ;
659659 it ( 'should not collapse margins of sibling phrasing children when enabled' , ( ) => {
660660 const { getByTestId } = render (
@@ -667,10 +667,8 @@ describe('RenderHTML', () => {
667667 enableExperimentalMarginCollapsing
668668 />
669669 ) ;
670- const div = getByTestId ( 'div' ) ;
671- const span = getByTestId ( 'span' ) ;
672- expect ( StyleSheet . flatten ( div . props . style ) . marginBottom ) . toBe ( 10 ) ;
673- expect ( StyleSheet . flatten ( span . props . style ) . marginTop ) . toBe ( 10 ) ;
670+ expect ( getByTestId ( 'div' ) ) . toHaveStyle ( { marginBottom : 10 } ) ;
671+ expect ( getByTestId ( 'span' ) ) . toHaveStyle ( { marginTop : 10 } ) ;
674672 } ) ;
675673
676674 it ( 'should not collapse margins of sibling children when disabled' , ( ) => {
@@ -684,10 +682,8 @@ describe('RenderHTML', () => {
684682 enableExperimentalMarginCollapsing = { false }
685683 />
686684 ) ;
687- const div = getByTestId ( 'div' ) ;
688- const p = getByTestId ( 'p' ) ;
689- expect ( StyleSheet . flatten ( div . props . style ) . marginBottom ) . toBe ( 10 ) ;
690- expect ( StyleSheet . flatten ( p . props . style ) . marginTop ) . toBe ( 10 ) ;
685+ expect ( getByTestId ( 'div' ) ) . toHaveStyle ( { marginBottom : 10 } ) ;
686+ expect ( getByTestId ( 'p' ) ) . toHaveStyle ( { marginTop : 10 } ) ;
691687 } ) ;
692688 } ) ;
693689 describe ( 'regarding renderersProps prop' , ( ) => {
@@ -831,7 +827,7 @@ describe('RenderHTML', () => {
831827 />
832828 ) ;
833829 const img = await findByTestId ( 'img' ) ;
834- expect ( StyleSheet . flatten ( img . props . style ) ) . toMatchObject ( {
830+ expect ( img ) . toHaveStyle ( {
835831 borderBottomWidth : 4
836832 } ) ;
837833 } ) ;
0 commit comments