@@ -20,12 +20,14 @@ const { Blob } = require('buffer');
20
20
const tmpdir = require ( '../common/tmpdir' ) ;
21
21
const testfile = path . join ( tmpdir . path , 'test-file-backed-blob.txt' ) ;
22
22
const testfile2 = path . join ( tmpdir . path , 'test-file-backed-blob2.txt' ) ;
23
+ const testfile3 = path . join ( tmpdir . path , 'test-file-backed-blob3.txt' ) ;
23
24
tmpdir . refresh ( ) ;
24
25
25
26
const data = `${ 'a' . repeat ( 1000 ) } ${ 'b' . repeat ( 2000 ) } ` ;
26
27
27
28
writeFileSync ( testfile , data ) ;
28
29
writeFileSync ( testfile2 , data . repeat ( 100 ) ) ;
30
+ writeFileSync ( testfile3 , '' ) ;
29
31
30
32
( async ( ) => {
31
33
const blob = await openAsBlob ( testfile ) ;
@@ -79,3 +81,21 @@ writeFileSync(testfile2, data.repeat(100));
79
81
80
82
await unlink ( testfile2 ) ;
81
83
} ) ( ) . then ( common . mustCall ( ) ) ;
84
+
85
+ ( async ( ) => {
86
+ const blob = await openAsBlob ( testfile3 ) ;
87
+ strictEqual ( blob . size , 0 ) ;
88
+ strictEqual ( await blob . text ( ) , '' ) ;
89
+ writeFileSync ( testfile3 , 'abc' ) ;
90
+ await rejects ( blob . text ( ) , { name : 'NotReadableError' } ) ;
91
+ await unlink ( testfile3 ) ;
92
+ } ) ( ) . then ( common . mustCall ( ) ) ;
93
+
94
+ ( async ( ) => {
95
+ const blob = await openAsBlob ( testfile3 ) ;
96
+ strictEqual ( blob . size , 0 ) ;
97
+ writeFileSync ( testfile3 , 'abc' ) ;
98
+ const stream = blob . stream ( ) ;
99
+ const reader = stream . getReader ( ) ;
100
+ await rejects ( ( ) => reader . read ( ) , { name : 'NotReadableError' } ) ;
101
+ } ) ( ) . then ( common . mustCall ( ) ) ;
0 commit comments