From 3e0da99040e30807cd84625d8c844cafcbdf247e Mon Sep 17 00:00:00 2001 From: ywpark1 Date: Tue, 9 Oct 2018 13:32:09 -0400 Subject: [PATCH] Fix issue-426: Add the test for fsPromises.readdir when the path exists, and is a directory (#452) --- tests/spec/fs.readdir.spec.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/spec/fs.readdir.spec.js b/tests/spec/fs.readdir.spec.js index da8d175..21449b6 100644 --- a/tests/spec/fs.readdir.spec.js +++ b/tests/spec/fs.readdir.spec.js @@ -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; + }); + }); }); /**