From a25d71b524ab20a9eb11cd683f8bc3ce68c0af92 Mon Sep 17 00:00:00 2001 From: Susan Truong Date: Fri, 21 Sep 2018 17:17:12 -0400 Subject: [PATCH] Fix #435: add a test for fsPromise.unlink() to delete a file that does not exist Make changes to `fsPromises.unlink()` to be more promise-friendly Added a newline to the end of the file Made a change to fsPromises.unlink() to be more friendly Changed the description of the promises test --- tests/spec/fs.unlink.spec.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/spec/fs.unlink.spec.js b/tests/spec/fs.unlink.spec.js index b087b4a..5adb168 100644 --- a/tests/spec/fs.unlink.spec.js +++ b/tests/spec/fs.unlink.spec.js @@ -105,7 +105,6 @@ describe('fs.unlink', function() { }); }); - describe('fs.promises.unlink', function () { beforeEach(util.setup); afterEach(util.cleanup); @@ -114,4 +113,14 @@ describe('fs.promises.unlink', function () { var fs = util.fs(); expect(fs.promises.unlink).to.be.a('function'); }); + + it('should return an error if trying to delete a file that does not exist', function() { + var fsPromises = util.fs().promises; + + return fsPromises.unlink('/myFile') + .catch(error => { + expect(error).to.exist; + expect(error.code).to.equal('ENOENT'); + }); + }); });