Fixes Issue#674: Refactored var declarations to const or let declarations to address i… (#676)
* Refactored var declarations to const or let declarations to address issue#674 * refactored let to const when variable does not change values
This commit is contained in:
parent
4de0bbfafd
commit
4a39dcc2f0
|
@ -1,18 +1,20 @@
|
||||||
var util = require('../lib/test-utils.js');
|
'use strict';
|
||||||
var expect = require('chai').expect;
|
|
||||||
|
const util = require('../lib/test-utils.js');
|
||||||
|
const expect = require('chai').expect;
|
||||||
|
|
||||||
describe('fs.chmod, fs.fchmod', function() {
|
describe('fs.chmod, fs.fchmod', function() {
|
||||||
beforeEach(util.setup);
|
beforeEach(util.setup);
|
||||||
afterEach(util.cleanup);
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
it('should be functions', function() {
|
it('should be functions', function() {
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
expect(typeof fs.chmod).to.equal('function');
|
expect(typeof fs.chmod).to.equal('function');
|
||||||
expect(typeof fs.fchmod).to.equal('function');
|
expect(typeof fs.fchmod).to.equal('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should automatically set mode=755 for a directory', function(done) {
|
it('should automatically set mode=755 for a directory', function(done) {
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/dir', function(err) {
|
fs.mkdir('/dir', function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -26,7 +28,7 @@ describe('fs.chmod, fs.fchmod', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should automatically set mode=644 for a file', function(done) {
|
it('should automatically set mode=644 for a file', function(done) {
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
|
|
||||||
fs.open('/file', 'w', function(err, fd) {
|
fs.open('/file', 'w', function(err, fd) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -40,7 +42,7 @@ describe('fs.chmod, fs.fchmod', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be an error when the path is invalid', function(done){
|
it('should be an error when the path is invalid', function(done){
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
fs.chmod('/invalid_path', 0o444, function(err){
|
fs.chmod('/invalid_path', 0o444, function(err){
|
||||||
expect(err).to.exist;
|
expect(err).to.exist;
|
||||||
expect(err.code).to.equal('ENOENT');
|
expect(err.code).to.equal('ENOENT');
|
||||||
|
@ -49,7 +51,7 @@ describe('fs.chmod, fs.fchmod', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should error if mode value is a non-numeric string', function(done) {
|
it('should error if mode value is a non-numeric string', function(done) {
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/dir', function(err) {
|
fs.mkdir('/dir', function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -63,7 +65,7 @@ describe('fs.chmod, fs.fchmod', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should error if mode value is null', function(done) {
|
it('should error if mode value is null', function(done) {
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/dir', function(err) {
|
fs.mkdir('/dir', function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -77,7 +79,7 @@ describe('fs.chmod, fs.fchmod', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should error if mode value is non-integer number', function(done) {
|
it('should error if mode value is non-integer number', function(done) {
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/dir', function(err) {
|
fs.mkdir('/dir', function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -91,7 +93,7 @@ describe('fs.chmod, fs.fchmod', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should error if mode value is non-integer number', function(done) {
|
it('should error if mode value is non-integer number', function(done) {
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/dir', function(err) {
|
fs.mkdir('/dir', function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -105,7 +107,7 @@ describe('fs.chmod, fs.fchmod', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow octal strings for mode value', function(done) {
|
it('should allow octal strings for mode value', function(done) {
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
|
|
||||||
fs.mkdir('/dir', function(err) {
|
fs.mkdir('/dir', function(err) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -124,7 +126,7 @@ describe('fs.chmod, fs.fchmod', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow for updating mode of a given file', function(done) {
|
it('should allow for updating mode of a given file', function(done) {
|
||||||
var fs = util.fs();
|
const fs = util.fs();
|
||||||
|
|
||||||
fs.open('/file', 'w', function(err, fd) {
|
fs.open('/file', 'w', function(err, fd) {
|
||||||
if(err) throw err;
|
if(err) throw err;
|
||||||
|
@ -161,12 +163,12 @@ describe('fsPromise.chmod', function() {
|
||||||
afterEach(util.setup);
|
afterEach(util.setup);
|
||||||
|
|
||||||
it('should be a function', function() {
|
it('should be a function', function() {
|
||||||
var fsPromise = util.fs().promises;
|
const fsPromise = util.fs().promises;
|
||||||
expect(typeof fsPromise.chmod).to.equal('function');
|
expect(typeof fsPromise.chmod).to.equal('function');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow for updating mode of a given file', function() {
|
it('should allow for updating mode of a given file', function() {
|
||||||
var fsPromise = util.fs().promises;
|
const fsPromise = util.fs().promises;
|
||||||
|
|
||||||
return fsPromise.open('/file', 'w')
|
return fsPromise.open('/file', 'w')
|
||||||
.then(() => fsPromise.chmod('/file', 0o444))
|
.then(() => fsPromise.chmod('/file', 0o444))
|
||||||
|
|
Loading…
Reference in New Issue