Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94a266e

Browse filesBrowse files
sivaprsItalo A. Casas
authored andcommitted
test: refactor the code in test-fs-watch.js
* used let and const instead of var * used assert.strictEqual instead assert.equal PR-URL: #10357 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Julian Duque <julianduquej@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 3575f51 commit 94a266e
Copy full SHA for 94a266e

File tree

Expand file treeCollapse file tree

1 file changed

+31
-31
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+31
-31
lines changed
Open diff view settings
Collapse file

‎test/sequential/test-fs-watch.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-fs-watch.js
+31-31Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var path = require('path');
5-
var fs = require('fs');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const path = require('path');
5+
const fs = require('fs');
66

7-
var expectFilePath = common.isWindows ||
8-
common.isLinux ||
9-
common.isOSX;
7+
const expectFilePath = common.isWindows ||
8+
common.isLinux ||
9+
common.isOSX;
1010

11-
var watchSeenOne = 0;
12-
var watchSeenTwo = 0;
13-
var watchSeenThree = 0;
11+
let watchSeenOne = 0;
12+
let watchSeenTwo = 0;
13+
let watchSeenThree = 0;
1414

15-
var testDir = common.tmpDir;
15+
const testDir = common.tmpDir;
1616

17-
var filenameOne = 'watch.txt';
18-
var filepathOne = path.join(testDir, filenameOne);
17+
const filenameOne = 'watch.txt';
18+
const filepathOne = path.join(testDir, filenameOne);
1919

20-
var filenameTwo = 'hasOwnProperty';
21-
var filepathTwo = filenameTwo;
22-
var filepathTwoAbs = path.join(testDir, filenameTwo);
20+
const filenameTwo = 'hasOwnProperty';
21+
const filepathTwo = filenameTwo;
22+
const filepathTwoAbs = path.join(testDir, filenameTwo);
2323

2424
process.on('exit', function() {
2525
assert.ok(watchSeenOne > 0);
@@ -33,12 +33,12 @@ fs.writeFileSync(filepathOne, 'hello');
3333

3434
assert.doesNotThrow(
3535
function() {
36-
var watcher = fs.watch(filepathOne);
36+
const watcher = fs.watch(filepathOne);
3737
watcher.on('change', function(event, filename) {
38-
assert.equal('change', event);
38+
assert.strictEqual('change', event);
3939

4040
if (expectFilePath) {
41-
assert.equal('watch.txt', filename);
41+
assert.strictEqual('watch.txt', filename);
4242
}
4343
watcher.close();
4444
++watchSeenOne;
@@ -57,11 +57,11 @@ fs.writeFileSync(filepathTwoAbs, 'howdy');
5757

5858
assert.doesNotThrow(
5959
function() {
60-
var watcher = fs.watch(filepathTwo, function(event, filename) {
61-
assert.equal('change', event);
60+
const watcher = fs.watch(filepathTwo, function(event, filename) {
61+
assert.strictEqual('change', event);
6262

6363
if (expectFilePath) {
64-
assert.equal('hasOwnProperty', filename);
64+
assert.strictEqual('hasOwnProperty', filename);
6565
}
6666
watcher.close();
6767
++watchSeenTwo;
@@ -79,13 +79,13 @@ const filepathThree = path.join(testsubdir, filenameThree);
7979

8080
assert.doesNotThrow(
8181
function() {
82-
var watcher = fs.watch(testsubdir, function(event, filename) {
83-
var renameEv = common.isSunOS ? 'change' : 'rename';
84-
assert.equal(renameEv, event);
82+
const watcher = fs.watch(testsubdir, function(event, filename) {
83+
const renameEv = common.isSunOS ? 'change' : 'rename';
84+
assert.strictEqual(renameEv, event);
8585
if (expectFilePath) {
86-
assert.equal('newfile.txt', filename);
86+
assert.strictEqual('newfile.txt', filename);
8787
} else {
88-
assert.equal(null, filename);
88+
assert.strictEqual(null, filename);
8989
}
9090
watcher.close();
9191
++watchSeenThree;
@@ -94,7 +94,7 @@ assert.doesNotThrow(
9494
);
9595

9696
setImmediate(function() {
97-
var fd = fs.openSync(filepathThree, 'w');
97+
const fd = fs.openSync(filepathThree, 'w');
9898
fs.closeSync(fd);
9999
});
100100

@@ -106,17 +106,17 @@ fs.watch(__filename, {persistent: false}, function() {
106106

107107
// whitebox test to ensure that wrapped FSEvent is safe
108108
// https://github.com/joyent/node/issues/6690
109-
var oldhandle;
109+
let oldhandle;
110110
assert.throws(function() {
111-
var w = fs.watch(__filename, function(event, filename) { });
111+
const w = fs.watch(__filename, function(event, filename) { });
112112
oldhandle = w._handle;
113113
w._handle = { close: w._handle.close };
114114
w.close();
115115
}, TypeError);
116116
oldhandle.close(); // clean up
117117

118118
assert.throws(function() {
119-
var w = fs.watchFile(__filename, {persistent: false}, function() {});
119+
const w = fs.watchFile(__filename, {persistent: false}, function() {});
120120
oldhandle = w._handle;
121121
w._handle = { stop: w._handle.stop };
122122
w.stop();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.