diff --git a/tests/spec/fs.rmdir.spec.js b/tests/spec/fs.rmdir.spec.js index 6e183be..de04079 100644 --- a/tests/spec/fs.rmdir.spec.js +++ b/tests/spec/fs.rmdir.spec.js @@ -121,3 +121,34 @@ describe('fs.rmdir', function() { }); }); }); + +describe('fs.promises.rmdir', function(){ + beforeEach(util.setup); + afterEach(util.cleanup); + + it('should return an error if the directory is not empty', function() { + var fs = util.fs(); + var fsPromises = fs.promises; + + return fsPromises.mkdir('/tmp') + .then(() => fsPromises.mkdir('/tmp/mydir')) + .then(() => fsPromises.rmdir('/')) + .catch(error => { + expect(error).to.exist; + expect(error.code).to.equal('EBUSY'); + }); + }); + + it('should return an error if the path is not a directory', function() { + var fs = util.fs(); + var fsPromises = fs.promises; + + return fsPromises.mkdir('/tmp') + .then(() => fsPromises.writeFile('/tmp/myfile','Hello World')) + .then(() => fsPromises.rmdir('/tmp/myfile')) + .catch(error => { + expect(error).to.exist; + expect(error.code).to.equal('ENOTDIR'); + }); + }); +});