Add test for fsPromises.rmdir() when dir not empty and dir is a file, Fix Issue 474 (#510)

* Saving files before refreshing line endings

* Adding test case for returning an error if the path is not a directory

* Add return for fsPromises, and few other small fixes

* Fix promises, and few done parameter

* Update fs.rmdir.spec.js
This commit is contained in:
Thanh Nguyen 2018-10-09 13:51:19 -04:00 committed by David Humphrey
parent beea03dbae
commit 2f3c384868
1 changed files with 31 additions and 0 deletions

View File

@ -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');
});
});
});