@@ -346,8 +346,23 @@ describe("stream", () => {
346
346
a : pl . Series ( "a" , [ 1 , 2 , 3 , 4 ] , pl . Int64 ) ,
347
347
b : pl . Series ( "b" , [ 2 , 2 , 2 , 2 ] , pl . Int64 ) ,
348
348
} ) ;
349
- const df = await pl . readJSONStream ( readStream ) ;
350
- expect ( df ) . toFrameEqual ( expected ) ;
349
+ const actual = await pl . readJSONStream ( readStream ) ;
350
+ expect ( actual ) . toFrameEqual ( expected ) ;
351
+ } ) ;
352
+
353
+ test ( "readJSON:lines" , async ( ) => {
354
+ const readStream = new Stream . Readable ( { read ( ) { } } ) ;
355
+ readStream . push ( `${ JSON . stringify ( { a : 1 , b : 2 } ) } \n` ) ;
356
+ readStream . push ( `${ JSON . stringify ( { a : 2 , b : 2 } ) } \n` ) ;
357
+ readStream . push ( `${ JSON . stringify ( { a : 3 , b : 2 } ) } \n` ) ;
358
+ readStream . push ( `${ JSON . stringify ( { a : 4 , b : 2 } ) } \n` ) ;
359
+ readStream . push ( null ) ;
360
+ const actual = await pl . readJSONStream ( readStream , { format : "lines" } ) ;
361
+ const expected = pl . DataFrame ( {
362
+ a : pl . Series ( "a" , [ 1 , 2 , 3 , 4 ] , pl . Int64 ) ,
363
+ b : pl . Series ( "b" , [ 2 , 2 , 2 , 2 ] , pl . Int64 ) ,
364
+ } ) ;
365
+ expect ( actual ) . toFrameEqual ( expected ) ;
351
366
} ) ;
352
367
353
368
test ( "readJSON:error" , async ( ) => {
@@ -357,7 +372,8 @@ describe("stream", () => {
357
372
readStream . push ( `${ JSON . stringify ( { a : 3 , b : 2 } ) } \n` ) ;
358
373
readStream . push ( "not parseable json " ) ;
359
374
readStream . push ( null ) ;
360
-
361
- await expect ( pl . readJSONStream ( readStream ) ) . rejects . toBeDefined ( ) ;
375
+ await expect (
376
+ pl . readJSONStream ( readStream , { format : "lines" } ) ,
377
+ ) . rejects . toBeDefined ( ) ;
362
378
} ) ;
363
379
} ) ;
0 commit comments