@@ -21,13 +21,17 @@ const tmpdir = require('../common/tmpdir');
2121const testfile = tmpdir . resolve ( 'test-file-backed-blob.txt' ) ;
2222const testfile2 = tmpdir . resolve ( 'test-file-backed-blob2.txt' ) ;
2323const 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' ) ;
2426tmpdir . refresh ( ) ;
2527
2628const data = `${ 'a' . repeat ( 1000 ) } ${ 'b' . repeat ( 2000 ) } ` ;
2729
2830writeFileSync ( 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 , '' ) ;
3135
3236( async ( ) => {
3337 const blob = await openAsBlob ( testfile ) ;
@@ -69,7 +73,7 @@ writeFileSync(testfile3, '');
6973
7074( async ( ) => {
7175 // Refs: https://github.com/nodejs/node/issues/47683
72- const blob = await openAsBlob ( testfile ) ;
76+ const blob = await openAsBlob ( testfile2 ) ;
7377 const res = blob . slice ( 10 , 20 ) ;
7478 const ab = await res . arrayBuffer ( ) ;
7579 strictEqual ( res . size , ab . byteLength ) ;
@@ -82,39 +86,41 @@ writeFileSync(testfile3, '');
8286
8387 const res1 = blob . slice ( 995 , 1005 ) ;
8488 strictEqual ( await res1 . text ( ) , data . slice ( 995 , 1005 ) ) ;
89+ await unlink ( testfile2 ) ;
8590} ) ( ) . then ( common . mustCall ( ) ) ;
8691
8792( async ( ) => {
88- const blob = await openAsBlob ( testfile2 ) ;
93+ const blob = await openAsBlob ( testfile3 ) ;
8994 const stream = blob . stream ( ) ;
9095 const read = async ( ) => {
9196 // eslint-disable-next-line no-unused-vars
9297 for await ( const _ of stream ) {
93- writeFileSync ( testfile2 , data + 'abc' ) ;
98+ writeFileSync ( testfile3 , data + 'abc' ) ;
9499 }
95100 } ;
96101
97102 await rejects ( read ( ) , { name : 'NotReadableError' } ) ;
98103
99- await unlink ( testfile2 ) ;
104+ await unlink ( testfile3 ) ;
100105} ) ( ) . then ( common . mustCall ( ) ) ;
101106
102107( async ( ) => {
103- const blob = await openAsBlob ( testfile3 ) ;
108+ const blob = await openAsBlob ( testfile4 ) ;
104109 strictEqual ( blob . size , 0 ) ;
105110 strictEqual ( await blob . text ( ) , '' ) ;
106- writeFileSync ( testfile3 , 'abc' ) ;
111+ writeFileSync ( testfile4 , 'abc' ) ;
107112 await rejects ( blob . text ( ) , { name : 'NotReadableError' } ) ;
108- await unlink ( testfile3 ) ;
113+ await unlink ( testfile4 ) ;
109114} ) ( ) . then ( common . mustCall ( ) ) ;
110115
111116( async ( ) => {
112- const blob = await openAsBlob ( testfile3 ) ;
117+ const blob = await openAsBlob ( testfile5 ) ;
113118 strictEqual ( blob . size , 0 ) ;
114- writeFileSync ( testfile3 , 'abc' ) ;
119+ writeFileSync ( testfile5 , 'abc' ) ;
115120 const stream = blob . stream ( ) ;
116121 const reader = stream . getReader ( ) ;
117122 await rejects ( ( ) => reader . read ( ) , { name : 'NotReadableError' } ) ;
123+ await unlink ( testfile5 ) ;
118124} ) ( ) . then ( common . mustCall ( ) ) ;
119125
120126( async ( ) => {
0 commit comments