* Fix Issue #400 - add test for passing file to fs.promise.readdir() This adds a test to ensure that `fs.promise.readdir()` throws an error when passing in a file. * Made changes to `fsPromises.readdir` to be more promise-friendly
This commit is contained in:
parent
e77361107e
commit
7e27c8be2c
|
@ -55,3 +55,24 @@ describe('fs.readdir', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fsPromises tests
|
||||||
|
*/
|
||||||
|
|
||||||
|
describe('fsPromises.readdir', function() {
|
||||||
|
beforeEach(util.setup);
|
||||||
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
|
it('should return an error if the path is a file', function() {
|
||||||
|
var fsPromises = util.fs().promises;
|
||||||
|
|
||||||
|
return fsPromises.open('/myfile', 'w')
|
||||||
|
.then(fd => fsPromises.close(fd))
|
||||||
|
.then(() => fsPromises.readdir('/myfile'))
|
||||||
|
.catch(error => {
|
||||||
|
expect(error).to.exist;
|
||||||
|
expect(error.code).to.equal('ENOTDIR');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue