From e77361107ef9e8d9e425a4f61bc592fd904b5066 Mon Sep 17 00:00:00 2001 From: Casva <43356579+Casva@users.noreply.github.com> Date: Tue, 9 Oct 2018 13:02:01 -0400 Subject: [PATCH] Issue 427 - Add tests to fsPromises.rmdir when directory doesn't exist and when trying to delete root directory (#457) * Fix #427 - Fixed indentation and ENOENT -> EBUSY on line 120 * Deleted extra line at the end of document * Fix #427 - Added tests for fsPromises.rmdir when trying to remove a nonexistent directory and when trying to remove root directory --- tests/spec/fs.rmdir.spec.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/spec/fs.rmdir.spec.js b/tests/spec/fs.rmdir.spec.js index 328c972..6e183be 100644 --- a/tests/spec/fs.rmdir.spec.js +++ b/tests/spec/fs.rmdir.spec.js @@ -97,4 +97,27 @@ describe('fs.rmdir', function() { }); }); }); + + it('(promise) should be a function', function() { + var fsPromises = util.fs().promises; + expect(fsPromises.rmdir).to.be.a('function'); + }); + + it('(promise) should return an error if the path does not exist', function() { + var fsPromises = util.fs().promises; + return fsPromises.rmdir('/tmp/mydir') + .catch(error => { + expect(error).to.exist; + expect(error.code).to.equal('ENOENT'); + }); + }); + + it('(promise) should return an error if attempting to remove the root directory', function() { + var fsPromises = util.fs().promises; + return fsPromises.rmdir('/') + .catch(error => { + expect(error).to.exist; + expect(error.code).to.equal('EBUSY'); + }); + }); });