From 934ef8bfa7605f2f50e97f6f92fe344a69979173 Mon Sep 17 00:00:00 2001 From: Stephen Truong Date: Tue, 9 Oct 2018 16:00:56 -0400 Subject: [PATCH] Fix #419: Add test for fsPromises.open() when the path does not exist (#455) * Fix #419: Add test for fsPromises.open() when the path does not exist * Update package.json * Fix #419: Add test for fsPromises.open() when the path does not exist Removed some unnecessary code based on reviews * Update fs.open.spec.js --- tests/spec/fs.open.spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/spec/fs.open.spec.js b/tests/spec/fs.open.spec.js index b995755..685a27d 100644 --- a/tests/spec/fs.open.spec.js +++ b/tests/spec/fs.open.spec.js @@ -137,3 +137,22 @@ describe('fs.open', function() { }); }); }); + +/** + * fsPromise.open() Tests + **/ +describe('fsPromises.open', function() { + beforeEach(util.setup); + afterEach(util.cleanup); + + it('should return an error if the parent path does not exist', function() { + var fsPromises = util.fs().promises; + + return fsPromises.open('/tmp/myfile', 'w+') + .then(result => expect(result).not.to.exist) + .catch(error => { + expect(error).to.exist; + expect(error.code).to.equal('ENOENT'); + }); + }); +});