From 0354c7e13e0b6976879fcfbd3fb9f83f6c13a272 Mon Sep 17 00:00:00 2001 From: rdittrich97 <37879652+rdittrich97@users.noreply.github.com> Date: Tue, 9 Oct 2018 12:54:40 -0400 Subject: [PATCH] Fix #423: added proimse support for fs.stat (#432) * added promise support to fs.stat * restored package lock * fixed lint issues * made tests more promise freindly * removed .catch statement from promise and fixed style issues * removed .catch statement from promise and fixed style issues --- tests/spec/fs.stat.spec.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/spec/fs.stat.spec.js b/tests/spec/fs.stat.spec.js index 16ee1bb..a2c9e4d 100644 --- a/tests/spec/fs.stat.spec.js +++ b/tests/spec/fs.stat.spec.js @@ -91,4 +91,33 @@ describe('fs.stat', function() { }); }); }); + + it('(promise) should be a function', function() { + var fs = util.fs(); + expect(fs.promises.stat).to.be.a('function'); + }); + + it('should return a promise', function() { + var fs = util.fs(); + expect(fs.promises.stat()).to.be.a('Promise'); + }); + + it('(promise) should return a stat object if file exists', function() { + var fs = util.fs(); + + return fs.promises + .stat('/') + .then(result => { + expect(result).to.exist; + + expect(result.node).to.be.a('string'); + expect(result.dev).to.equal(fs.name); + expect(result.size).to.be.a('number'); + expect(result.nlinks).to.be.a('number'); + expect(result.atime).to.be.a('number'); + expect(result.mtime).to.be.a('number'); + expect(result.ctime).to.be.a('number'); + expect(result.type).to.equal('DIRECTORY'); + }); + }); });