Skip to content

Commit

Permalink
Addressed Issue #703 (#711)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dcoull authored and humphd committed Mar 5, 2019
1 parent ee56794 commit 94d5ff8
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions tests/spec/times.spec.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;

Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 94d5ff8

Please sign in to comment.