@@ -990,5 +990,33 @@ onlyOnNode20('FsaNodeFs', () => {
990990 '/mountpoint/f.html' : 'test' ,
991991 } ) ;
992992 } ) ;
993+
994+ test ( 'can read with start position beyond file size' , async ( ) => {
995+ const { fs, vol } = setup ( { folder : { file : 'test' } , 'empty-folder' : null , 'f.html' : 'test' } ) ;
996+ const readStream = fs . createReadStream ( '/folder/file' , { start : 100 } ) ;
997+ const writeStream = fs . createWriteStream ( '/folder/file2' ) ;
998+ readStream . pipe ( writeStream ) ;
999+ await new Promise ( resolve => writeStream . once ( 'close' , resolve ) ) ;
1000+ expect ( vol . toJSON ( ) ) . toStrictEqual ( {
1001+ '/mountpoint/folder/file' : 'test' ,
1002+ '/mountpoint/folder/file2' : '' ,
1003+ '/mountpoint/empty-folder' : null ,
1004+ '/mountpoint/f.html' : 'test' ,
1005+ } ) ;
1006+ } ) ;
1007+
1008+ test ( 'can read with start position at file size' , async ( ) => {
1009+ const { fs, vol } = setup ( { folder : { file : 'test' } , 'empty-folder' : null , 'f.html' : 'test' } ) ;
1010+ const readStream = fs . createReadStream ( '/folder/file' , { start : 4 } ) ;
1011+ const writeStream = fs . createWriteStream ( '/folder/file3' ) ;
1012+ readStream . pipe ( writeStream ) ;
1013+ await new Promise ( resolve => writeStream . once ( 'close' , resolve ) ) ;
1014+ expect ( vol . toJSON ( ) ) . toStrictEqual ( {
1015+ '/mountpoint/folder/file' : 'test' ,
1016+ '/mountpoint/folder/file3' : '' ,
1017+ '/mountpoint/empty-folder' : null ,
1018+ '/mountpoint/f.html' : 'test' ,
1019+ } ) ;
1020+ } ) ;
9931021 } ) ;
9941022} ) ;
0 commit comments