Skip to content

Commit 1cd74bf

Browse files
committed
add test from #19
1 parent 0758107 commit 1cd74bf

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/basic.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,29 @@ test('directory filename resolves correctly', function (t) {
414414
t.is(file.filename, path.join(tmp, name))
415415
})
416416

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+
417440
function gen () {
418441
return path.join(tmp, ++i + '.txt')
419442
}

0 commit comments

Comments
 (0)