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:
parent
beea03dbae
commit
2f3c384868
|
@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue