@@ -59,6 +59,39 @@ describe("delimited file previews", () => {
5959 expect ( table . rows [ 0 ] ?. [ 0 ] ) . toHaveLength ( 2000 ) ;
6060 expect ( parseDelimitedPreview ( 'a,"unfinished' , "," ) . truncated ) . toBe ( true ) ;
6161 } ) ;
62+ describe . each ( [ "," , "\t" ] as const ) ( "Unicode cells with delimiter %j" , ( delimiter ) => {
63+ it . each ( [ false , true ] ) ( "does not split surrogate pairs in quoted=%s cells" , ( quoted ) => {
64+ const prefix = "x" . repeat ( 1999 ) ;
65+ const value = `${ prefix } 😀tail` ;
66+ const input = `${ quoted ? `"${ value } "` : value } ${ delimiter } next\nlast` ;
67+ expect ( parseDelimitedPreview ( input , delimiter ) ) . toEqual ( {
68+ rows : [ [ prefix , "next" ] , [ "last" ] ] ,
69+ truncated : true ,
70+ } ) ;
71+ } ) ;
72+ it ( "keeps pairs that fit and truncates later characters" , ( ) => {
73+ const value = `${ "x" . repeat ( 1998 ) } 😀` ;
74+ expect ( parseDelimitedPreview ( value , delimiter ) ) . toEqual ( {
75+ rows : [ [ value ] ] ,
76+ truncated : false ,
77+ } ) ;
78+ expect ( parseDelimitedPreview ( `${ value } tail` , delimiter ) ) . toEqual ( {
79+ rows : [ [ value ] ] ,
80+ truncated : true ,
81+ } ) ;
82+ } ) ;
83+ it ( "keeps escaped quotes and BMP text at the same limit" , ( ) => {
84+ const prefix = "x" . repeat ( 1999 ) ;
85+ expect ( parseDelimitedPreview ( `"${ prefix } ""tail"` , delimiter ) ) . toEqual ( {
86+ rows : [ [ `${ prefix } "` ] ] ,
87+ truncated : true ,
88+ } ) ;
89+ expect ( parseDelimitedPreview ( `${ prefix } éextra` , delimiter ) ) . toEqual ( {
90+ rows : [ [ `${ prefix } é` ] ] ,
91+ truncated : true ,
92+ } ) ;
93+ } ) ;
94+ } ) ;
6295 it ( "reads worker pages beyond the old row, column and cell limits" , ( ) => {
6396 const text = Array . from ( { length : 128 } , ( _ , row ) =>
6497 Array . from ( { length : 40 } , ( _ , column ) => `${ row } :${ column } ` ) . join ( "," ) ,
0 commit comments