Add tests for mkdir with {recursive:true|false}

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2018-09-20 18:23:27 -04:00
parent 84c5433a28
commit 07eb047213
1 changed files with 37 additions and 0 deletions

View File

@ -45,4 +45,41 @@ describe('fs.mkdir', function() {
}); });
}); });
}); });
it('should error if {recursive:true} is not specified on a deep path', function(done) {
var fs = util.fs();
fs.mkdir('/tmp/deep/path', function(error) {
expect(error).to.exist;
expect(error.code).to.equal('ENOENT');
done();
});
});
it('should error if only a mode is specified on a deep path (should default to recursive:false)', function(done) {
var fs = util.fs();
fs.mkdir('/tmp/deep/path', 0o777, function(error) {
expect(error).to.exist;
expect(error.code).to.equal('ENOENT');
done();
});
});
it('should create all paths if {recursive:true} is specified on a deep path', function(done) {
var fs = util.fs();
fs.mkdir('/tmp/deep/path', {recursive:true}, function(error) {
expect(error).not.to.exist;
if(error) throw error;
fs.stat('/tmp/deep/path', function(error, stats) {
expect(error).not.to.exist;
expect(stats).to.exist;
expect(stats.type).to.equal('DIRECTORY');
done();
});
});
});
}); });