1
+ /* eslint-disable testing-library/no-node-access */
2
+
1
3
import * as React from 'react' ;
2
4
3
5
import { render , screen } from '@testing-library/react' ;
@@ -61,7 +63,6 @@ describe('BlocksRenderer', () => {
61
63
expect ( boldTag [ 1 ] ) . toHaveTextContent ( / a n d b o l d u n d e r l i n e s / i) ;
62
64
63
65
// Should still fallback to default components
64
- // eslint-disable-next-line testing-library/no-node-access
65
66
const underlineTag = document . querySelector ( 'u' ) ;
66
67
expect ( underlineTag ) . toHaveTextContent ( / a n d b o l d u n d e r l i n e s / i) ;
67
68
} ) ;
@@ -83,7 +84,6 @@ describe('BlocksRenderer', () => {
83
84
/>
84
85
) ;
85
86
86
- // eslint-disable-next-line testing-library/no-node-access
87
87
const paragraph = screen . getByText ( 'A paragraph' ) . closest ( 'p' ) ;
88
88
expect ( paragraph ) . toHaveTextContent ( 'A paragraph with bold' ) ;
89
89
} ) ;
@@ -109,12 +109,28 @@ describe('BlocksRenderer', () => {
109
109
/>
110
110
) ;
111
111
112
- // eslint-disable-next-line testing-library/no-node-access
113
112
const brElement = screen . getByText ( 'First paragraph' ) . nextElementSibling ;
114
113
expect ( brElement ) . toBeInTheDocument ( ) ;
115
114
expect ( brElement ?. tagName ) . toBe ( 'BR' ) ;
116
115
} ) ;
117
116
117
+ it ( 'renders paragraphs with line breaks' , ( ) => {
118
+ render (
119
+ < BlocksRenderer
120
+ content = { [
121
+ {
122
+ type : 'paragraph' ,
123
+ children : [ { type : 'text' , text : 'First line\nSecond line' } ] ,
124
+ } ,
125
+ ] }
126
+ />
127
+ ) ;
128
+
129
+ const paragraph = screen . getByText ( / F i r s t l i n e / ) . closest ( 'p' ) ;
130
+ const paragraphParts = paragraph ?. innerHTML ?. split ( '<br>' ) ;
131
+ expect ( paragraphParts ) . toEqual ( [ 'First line' , 'Second line' ] ) ;
132
+ } ) ;
133
+
118
134
it ( 'renders quotes' , ( ) => {
119
135
render (
120
136
< BlocksRenderer
@@ -129,7 +145,6 @@ describe('BlocksRenderer', () => {
129
145
130
146
const quote = screen . getByText ( 'A quote' ) ;
131
147
expect ( quote ) . toBeInTheDocument ( ) ;
132
- // eslint-disable-next-line testing-library/no-node-access
133
148
expect ( quote . closest ( 'blockquote' ) ) . toBeInTheDocument ( ) ;
134
149
} ) ;
135
150
@@ -142,9 +157,7 @@ describe('BlocksRenderer', () => {
142
157
143
158
const code = screen . getByText ( 'my code' ) ;
144
159
expect ( code ) . toBeInTheDocument ( ) ;
145
- // eslint-disable-next-line testing-library/no-node-access
146
160
expect ( code . closest ( 'code' ) ) . toBeInTheDocument ( ) ;
147
- // eslint-disable-next-line testing-library/no-node-access
148
161
expect ( code . closest ( 'pre' ) ) . toBeInTheDocument ( ) ;
149
162
} ) ;
150
163
@@ -322,13 +335,11 @@ describe('BlocksRenderer', () => {
322
335
const text = screen . getByText ( 'My text' ) ;
323
336
expect ( text ) . toBeInTheDocument ( ) ;
324
337
325
- /* eslint-disable testing-library/no-node-access */
326
338
expect ( text . closest ( 'strong' ) ) . toBeInTheDocument ( ) ;
327
339
expect ( text . closest ( 'em' ) ) . toBeInTheDocument ( ) ;
328
340
expect ( text . closest ( 'u' ) ) . toBeInTheDocument ( ) ;
329
341
expect ( text . closest ( 'del' ) ) . toBeInTheDocument ( ) ;
330
342
expect ( text . closest ( 'code' ) ) . toBeInTheDocument ( ) ;
331
- /* eslint-enable testing-library/no-node-access */
332
343
} ) ;
333
344
334
345
it ( 'ignores disabled or unknown modifiers' , ( ) => {
@@ -357,7 +368,6 @@ describe('BlocksRenderer', () => {
357
368
const text = screen . getByText ( 'My text' ) ;
358
369
expect ( text ) . toBeInTheDocument ( ) ;
359
370
360
- // eslint-disable-next-line testing-library/no-node-access
361
371
expect ( text . closest ( 'strong' ) ) . not . toBeInTheDocument ( ) ;
362
372
363
373
console . warn = originalWarn ;
0 commit comments