@@ -232,33 +232,33 @@ describe("chunkText", () => {
232232} ) ;
233233
234234describe ( "chunkByParagraph Unicode line/paragraph separators" , ( ) => {
235- it ( "treats lone U+2029 as a standalone paragraph boundary" , ( ) => {
236- // PARAGRAPH SEPARATOR is the semantic equivalent of a blank line.
237- // Use a limit small enough to force the split (normalized text is 40 chars).
238- const result = chunkByParagraph ( "paragraph one\u2029paragraph two starts here" , 39 ) ;
239- const expected = chunkByParagraph ( "paragraph one\n\nparagraph two starts here" , 39 ) ;
240-
241- expect ( result ) . toEqual ( [ "paragraph one" , "paragraph two starts here" ] ) ;
242- // Output is identical to \n\n (blank-line) input.
243- expect ( result ) . toEqual ( expected ) ;
244- } ) ;
245-
246- it ( "treats lone U+2028 as a single line break within one paragraph", ( ) => {
247- // LINE SEPARATOR is a single newline \u2014 no blank line, so the paragraph stays intact.
248- const result = chunkByParagraph ( "paragraph one line\u2028still same paragraph" , 50 ) ;
249- const expected = chunkByParagraph ( "paragraph one line\nstill same paragraph" , 50 ) ;
250-
251- expect ( result ) . toEqual ( [ "paragraph one line\nstill same paragraph" ] ) ;
252- expect ( result ) . toEqual ( expected ) ;
253- } ) ;
254-
255- it ( "treats consecutive U+2028 and U+2029 as a paragraph boundary ", ( ) => {
256- // U+2029 \u2192 \n\n, U+2028 \u2192 \n \u2192 combined they form a blank line.
257- const result = chunkByParagraph ( "paragraph one line\u2028\u2029paragraph two starts here" , 40 ) ;
258- const expected = chunkByParagraph ( "paragraph one line\n\nparagraph two starts here" , 40 ) ;
235+ it . each ( [
236+ {
237+ name : "treats lone U+2029 as a standalone paragraph boundary" ,
238+ text : "paragraph one\u2029paragraph two starts here" ,
239+ normalized : "paragraph one\n\nparagraph two starts here" ,
240+ limit : 39 ,
241+ expected : [ "paragraph one" , "paragraph two starts here" ] ,
242+ } ,
243+ {
244+ name : "treats lone U+2028 as a line break within one paragraph" ,
245+ text : "paragraph one line\u2028still same paragraph" ,
246+ normalized : "paragraph one line\nstill same paragraph",
247+ limit : 50 ,
248+ expected : [ "paragraph one line\nstill same paragraph" ] ,
249+ } ,
250+ {
251+ name : "treats consecutive U+2028 and U+2029 as a paragraph boundary" ,
252+ text : "paragraph one line\u2028\u2029paragraph two starts here" ,
253+ normalized : "paragraph one line\n\nparagraph two starts here" ,
254+ limit : 40 ,
255+ expected : [ " paragraph one line ", "paragraph two starts here" ] ,
256+ } ,
257+ ] as const ) ( "$name" , ( { text , normalized , limit , expected } ) => {
258+ const chunks = chunkByParagraph ( text , limit ) ;
259259
260- expect ( result ) . toEqual ( [ "paragraph one line" , "paragraph two starts here" ] ) ;
261- expect ( result ) . toEqual ( expected ) ;
260+ expect ( chunks ) . toEqual ( expected ) ;
261+ expect ( chunks ) . toEqual ( chunkByParagraph ( normalized , limit ) ) ;
262262 } ) ;
263263} ) ;
264264
0 commit comments