File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -414,6 +414,29 @@ test('directory filename resolves correctly', function (t) {
414
414
t . is ( file . filename , path . join ( tmp , name ) )
415
415
} )
416
416
417
+ test ( 'destroy' , async function ( t ) {
418
+ t . plan ( 5 )
419
+
420
+ const name = gen ( )
421
+ const file = new RAF ( name )
422
+
423
+ file . write ( 0 , Buffer . from ( 'hi' ) , function ( err ) {
424
+ t . absent ( err , 'no error' )
425
+ file . read ( 0 , 2 , function ( err , buf ) {
426
+ t . absent ( err , 'no error' )
427
+ t . alike ( buf , Buffer . from ( 'hi' ) )
428
+ file . destroy ( ondestroy )
429
+ } )
430
+ } )
431
+
432
+ function ondestroy ( err ) {
433
+ t . absent ( err , 'no error' )
434
+ fs . stat ( name , function ( err ) {
435
+ t . is ( err && err . code , 'ENOENT' , 'should be removed' )
436
+ } )
437
+ }
438
+ } )
439
+
417
440
function gen ( ) {
418
441
return path . join ( tmp , ++ i + '.txt' )
419
442
}
You can’t perform that action at this time.
0 commit comments