From 94d5ff879505b167fdbc095604eae000da40e00c Mon Sep 17 00:00:00 2001 From: dcoull Date: Tue, 5 Mar 2019 15:46:23 -0500 Subject: [PATCH] Addressed Issue #703 (#711) * update from var to let and const * Update from var to let and const * Update times.spec.js from var to let and const * Strict mode addition, migrated let usage to const * Revert changes to package-lock.json --- tests/spec/times.spec.js | 73 ++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/tests/spec/times.spec.js b/tests/spec/times.spec.js index 4ee431a..b4feb6e 100644 --- a/tests/spec/times.spec.js +++ b/tests/spec/times.spec.js @@ -1,15 +1,16 @@ -var util = require('../lib/test-utils.js'); -var expect = require('chai').expect; +'use strict'; +const util = require('../lib/test-utils.js'); +const expect = require('chai').expect; describe('node times (atime, mtime, ctimeMs)', function() { beforeEach(util.setup); afterEach(util.cleanup); - var dirname = '/dir'; - var filename = '/dir/file'; + const dirname = '/dir'; + const filename = '/dir/file'; function createTree(callback) { - var fs = util.fs(); + const fs = util.fs(); fs.mkdir(dirname, function(error) { if(error) throw error; @@ -22,7 +23,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { } function stat(path, callback) { - var fs = util.fs(); + const fs = util.fs(); fs.stat(path, function(error, stats) { if(error) throw error; @@ -31,8 +32,8 @@ describe('node times (atime, mtime, ctimeMs)', function() { } it('should update ctime when calling fs.rename()', function(done) { - var fs = util.fs(); - var newfilename = filename + '1'; + const fs = util.fs(); + const newfilename = filename + '1'; createTree(function() { stat(filename, function(stats1) { @@ -52,7 +53,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, mtime, atime when calling fs.truncate()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -72,7 +73,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, mtime, atime when calling fs.ftruncate()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -97,7 +98,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.stat()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -115,7 +116,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.fstat()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -138,7 +139,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.lstat()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { fs.link(filename, '/link', function(error) { @@ -159,7 +160,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.exists()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -181,7 +182,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, atime when calling fs.link()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -200,7 +201,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.symlink()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -219,7 +220,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.readlink()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { fs.symlink(filename, '/link', function(error) { @@ -243,7 +244,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, atime, mtime of parent dir when calling fs.unlink()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(dirname, function(stats1) { @@ -262,7 +263,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, atime, mtime of parent dir when calling fs.rmdir()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat('/', function(stats1) { @@ -286,7 +287,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, atime, mtime of parent dir when calling fs.mkdir()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat('/', function(stats1) { @@ -306,7 +307,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.close()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { fs.open(filename, 'w', function(error, fd) { @@ -329,7 +330,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.open()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -353,8 +354,8 @@ describe('node times (atime, mtime, ctimeMs)', function() { */ it('should update atime, ctime, mtime when calling fs.write()', function(done) { - var fs = util.fs(); - var buffer = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); + const fs = util.fs(); + const buffer = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); createTree(function() { fs.open('/myfile', 'w', function(error, fd) { @@ -382,8 +383,8 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.read()', function(done) { - var fs = util.fs(); - var buffer = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); + const fs = util.fs(); + const buffer = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]); createTree(function() { fs.open('/myfile', 'w', function(err, fd) { @@ -400,7 +401,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { if(error) throw error; stat('/myfile', function(stats1) { - var buffer2 = Buffer.alloc(buffer.length); + const buffer2 = Buffer.alloc(buffer.length); fs.read(fd, buffer2, 0, buffer2.length, 0, function(err, nbytes) { if(err) throw err; @@ -426,7 +427,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.readFile()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -446,7 +447,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update atime, ctime, mtime when calling fs.writeFile()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -465,7 +466,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update atime, ctime, mtime when calling fs.appendFile()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -484,7 +485,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, atime when calling fs.setxattr()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { stat(filename, function(stats1) { @@ -503,7 +504,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, atime when calling fs.fsetxattr()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { fs.open(filename, 'w', function(error, fd) { @@ -526,7 +527,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.getxattr()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { fs.setxattr(filename, 'extra', 'data', function(error) { @@ -550,7 +551,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should make no change when calling fs.fgetxattr()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { fs.open(filename, 'w', function(error, fd) { @@ -578,7 +579,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, atime when calling fs.removexattr()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { fs.setxattr(filename, 'extra', 'data', function(error) { @@ -601,7 +602,7 @@ describe('node times (atime, mtime, ctimeMs)', function() { }); it('should update ctime, atime when calling fs.fremovexattr()', function(done) { - var fs = util.fs(); + const fs = util.fs(); createTree(function() { fs.open(filename, 'w', function(error, fd) {