@@ -21,13 +21,17 @@ const tmpdir = require('../common/tmpdir');
21
21
const testfile = tmpdir . resolve ( 'test-file-backed-blob.txt' ) ;
22
22
const testfile2 = tmpdir . resolve ( 'test-file-backed-blob2.txt' ) ;
23
23
const testfile3 = tmpdir . resolve ( 'test-file-backed-blob3.txt' ) ;
24
+ const testfile4 = tmpdir . resolve ( 'test-file-backed-blob4.txt' ) ;
25
+ const testfile5 = tmpdir . resolve ( 'test-file-backed-blob5.txt' ) ;
24
26
tmpdir . refresh ( ) ;
25
27
26
28
const data = `${ 'a' . repeat ( 1000 ) } ${ 'b' . repeat ( 2000 ) } ` ;
27
29
28
30
writeFileSync ( testfile , data ) ;
29
- writeFileSync ( testfile2 , data . repeat ( 100 ) ) ;
30
- writeFileSync ( testfile3 , '' ) ;
31
+ writeFileSync ( testfile2 , data ) ;
32
+ writeFileSync ( testfile3 , data . repeat ( 100 ) ) ;
33
+ writeFileSync ( testfile4 , '' ) ;
34
+ writeFileSync ( testfile5 , '' ) ;
31
35
32
36
( async ( ) => {
33
37
const blob = await openAsBlob ( testfile ) ;
@@ -69,7 +73,7 @@ writeFileSync(testfile3, '');
69
73
70
74
( async ( ) => {
71
75
// Refs: https://github.com/nodejs/node/issues/47683
72
- const blob = await openAsBlob ( testfile ) ;
76
+ const blob = await openAsBlob ( testfile2 ) ;
73
77
const res = blob . slice ( 10 , 20 ) ;
74
78
const ab = await res . arrayBuffer ( ) ;
75
79
strictEqual ( res . size , ab . byteLength ) ;
@@ -82,39 +86,41 @@ writeFileSync(testfile3, '');
82
86
83
87
const res1 = blob . slice ( 995 , 1005 ) ;
84
88
strictEqual ( await res1 . text ( ) , data . slice ( 995 , 1005 ) ) ;
89
+ await unlink ( testfile2 ) ;
85
90
} ) ( ) . then ( common . mustCall ( ) ) ;
86
91
87
92
( async ( ) => {
88
- const blob = await openAsBlob ( testfile2 ) ;
93
+ const blob = await openAsBlob ( testfile3 ) ;
89
94
const stream = blob . stream ( ) ;
90
95
const read = async ( ) => {
91
96
// eslint-disable-next-line no-unused-vars
92
97
for await ( const _ of stream ) {
93
- writeFileSync ( testfile2 , data + 'abc' ) ;
98
+ writeFileSync ( testfile3 , data + 'abc' ) ;
94
99
}
95
100
} ;
96
101
97
102
await rejects ( read ( ) , { name : 'NotReadableError' } ) ;
98
103
99
- await unlink ( testfile2 ) ;
104
+ await unlink ( testfile3 ) ;
100
105
} ) ( ) . then ( common . mustCall ( ) ) ;
101
106
102
107
( async ( ) => {
103
- const blob = await openAsBlob ( testfile3 ) ;
108
+ const blob = await openAsBlob ( testfile4 ) ;
104
109
strictEqual ( blob . size , 0 ) ;
105
110
strictEqual ( await blob . text ( ) , '' ) ;
106
- writeFileSync ( testfile3 , 'abc' ) ;
111
+ writeFileSync ( testfile4 , 'abc' ) ;
107
112
await rejects ( blob . text ( ) , { name : 'NotReadableError' } ) ;
108
- await unlink ( testfile3 ) ;
113
+ await unlink ( testfile4 ) ;
109
114
} ) ( ) . then ( common . mustCall ( ) ) ;
110
115
111
116
( async ( ) => {
112
- const blob = await openAsBlob ( testfile3 ) ;
117
+ const blob = await openAsBlob ( testfile5 ) ;
113
118
strictEqual ( blob . size , 0 ) ;
114
- writeFileSync ( testfile3 , 'abc' ) ;
119
+ writeFileSync ( testfile5 , 'abc' ) ;
115
120
const stream = blob . stream ( ) ;
116
121
const reader = stream . getReader ( ) ;
117
122
await rejects ( ( ) => reader . read ( ) , { name : 'NotReadableError' } ) ;
123
+ await unlink ( testfile5 ) ;
118
124
} ) ( ) . then ( common . mustCall ( ) ) ;
119
125
120
126
( async ( ) => {
0 commit comments