@@ -22,6 +22,7 @@ jest.mock('react-native-render-html', () => {
2222 return ReactModule . createElement ( MockView ) ;
2323 } ,
2424 TNodeChildrenRenderer : ( { tnode} : { tnode ?: { mockText ?: string } } ) => ReactModule . createElement ( MockText , null , tnode ?. mockText ?? '' ) ,
25+ TNodeRenderer : ( { tnode} : { tnode ?: { mockText ?: string } } ) => ReactModule . createElement ( MockText , null , tnode ?. mockText ?? '' ) ,
2526 } ;
2627} ) ;
2728
@@ -33,28 +34,48 @@ jest.mock('@libs/Parser', () => ({
3334} ) ) ;
3435
3536const buildTNode = ( text = '' ) => ( { mockText : text } ) as unknown as CustomRendererProps < TBlock > [ 'tnode' ] ;
37+ const buildULTNode = ( children : Array < { tagName : string ; text : string } > ) =>
38+ ( {
39+ children : children . map ( ( child ) => ( { tagName : child . tagName , mockText : child . text } ) ) ,
40+ } ) as unknown as CustomRendererProps < TBlock > [ 'tnode' ] ;
3641
3742describe ( 'Bullet list rendering' , ( ) => {
3843 beforeEach ( ( ) => {
3944 capturedSource . html = undefined ;
4045 } ) ;
4146
4247 describe ( 'ULRenderer' , ( ) => {
43- it ( 'renders its children ' , ( ) => {
48+ it ( 'wraps each <li> child with a bullet marker ' , ( ) => {
4449 render (
4550 // @ts -expect-error — only the props read by the renderer are needed for this test
4651 < ULRenderer
47- tnode = { buildTNode ( 'child content' ) }
52+ tnode = { buildULTNode ( [
53+ { tagName : 'li' , text : 'One' } ,
54+ { tagName : 'li' , text : 'Two' } ,
55+ ] ) }
4856 style = { { } }
4957 /> ,
5058 ) ;
51- expect ( screen . getByText ( 'child content' ) ) . toBeTruthy ( ) ;
59+ expect ( screen . getAllByText ( CONST . DOT_SEPARATOR ) ) . toHaveLength ( 2 ) ;
60+ expect ( screen . getByText ( 'One' ) ) . toBeTruthy ( ) ;
61+ expect ( screen . getByText ( 'Two' ) ) . toBeTruthy ( ) ;
62+ } ) ;
63+
64+ it ( 'renders non-<li> children with the default node renderer' , ( ) => {
65+ render (
66+ // @ts -expect-error — only the props read by the renderer are needed for this test
67+ < ULRenderer
68+ tnode = { buildULTNode ( [ { tagName : 'span' , text : 'stray child' } ] ) }
69+ style = { { } }
70+ /> ,
71+ ) ;
72+ expect ( screen . queryByText ( CONST . DOT_SEPARATOR ) ) . toBeNull ( ) ;
73+ expect ( screen . getByText ( 'stray child' ) ) . toBeTruthy ( ) ;
5274 } ) ;
5375 } ) ;
5476
5577 describe ( 'BulletItemRenderer (used for both <li> and <bullet-item>)' , ( ) => {
5678 it ( 'renders a bullet marker next to the item content' , ( ) => {
57- // @ts -expect-error — only the props read by the renderer are needed for this test
5879 render ( < BulletItemRenderer tnode = { buildTNode ( 'First item' ) } /> ) ;
5980 expect ( screen . getByText ( CONST . DOT_SEPARATOR ) ) . toBeTruthy ( ) ;
6081 expect ( screen . getByText ( 'First item' ) ) . toBeTruthy ( ) ;
0 commit comments