Fix issue-426: Add the test for fsPromises.readdir when the path exists, and is a directory (#452)

This commit is contained in:
ywpark1 2018-10-09 13:32:09 -04:00 committed by David Humphrey
parent 02bd6d8a62
commit 3e0da99040
1 changed files with 29 additions and 0 deletions

View File

@ -54,6 +54,35 @@ describe('fs.readdir', function() {
});
});
});
it('(promise) should be a function', function() {
var fsPromises = util.fs().promises;
expect(fsPromises.readdir).to.be.a('function');
});
it('(promise) should return a list of files from an existing directory', function() {
var fsPromises = util.fs().promises;
return fsPromises.mkdir('/tmp')
.then(() => {
return fsPromises.stat('/');
})
.then(stats => {
expect(stats).to.exist;
expect(stats.isDirectory()).to.be.true;
})
.then(() => {
return fsPromises.readdir('/');
})
.then(files => {
expect(files).to.exist;
expect(files.length).to.equal(1);
expect(files[0]).to.equal('tmp');
})
.catch(error => {
expect(error).not.to.exist;
});
});
});
/**