Skip to content

Commit eca74a9

Browse files
paulgrockjasnell
authored andcommitted
test: cleanup test require symlink
* Changed `==` to `includes` for clarity. * Switched to `assert.strictEqual` from `assert.equal` * Changed some `var` to `const` * Test cleanup with `common.refreshTmpDir` PR-URL: #8305 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent a3c5567 commit eca74a9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/parallel/test-require-symlink.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const fs = require('fs');
77
const exec = require('child_process').exec;
88
const spawn = require('child_process').spawn;
99

10+
common.refreshTmpDir();
11+
1012
const linkTarget = path.join(common.fixturesDir,
1113
'/module-require-symlink/node_modules/dep2/');
1214

@@ -22,8 +24,8 @@ if (common.isWindows) {
2224
// On Windows, creating symlinks requires admin privileges.
2325
// We'll only try to run symlink test if we have enough privileges.
2426
exec('whoami /priv', function(err, o) {
25-
if (err || o.indexOf('SeCreateSymbolicLinkPrivilege') == -1) {
26-
console.log('Skipped: insufficient privileges');
27+
if (err || !o.includes('SeCreateSymbolicLinkPrivilege')) {
28+
common.skip('insufficient privileges');
2729
return;
2830
} else {
2931
test();
@@ -36,21 +38,20 @@ if (common.isWindows) {
3638
function test() {
3739
process.on('exit', function() {
3840
fs.unlinkSync(linkDir);
39-
fs.unlinkSync(linkScript);
4041
});
4142

4243
fs.symlinkSync(linkTarget, linkDir);
4344
fs.symlinkSync(linkScriptTarget, linkScript);
4445

4546
// load symlinked-module
46-
var fooModule =
47+
const fooModule =
4748
require(path.join(common.fixturesDir, '/module-require-symlink/foo.js'));
48-
assert.equal(fooModule.dep1.bar.version, 'CORRECT_VERSION');
49-
assert.equal(fooModule.dep2.bar.version, 'CORRECT_VERSION');
49+
assert.strictEqual(fooModule.dep1.bar.version, 'CORRECT_VERSION');
50+
assert.strictEqual(fooModule.dep2.bar.version, 'CORRECT_VERSION');
5051

5152
// load symlinked-script as main
52-
var node = process.execPath;
53-
var child = spawn(node, ['--preserve-symlinks', linkScript]);
53+
const node = process.execPath;
54+
const child = spawn(node, ['--preserve-symlinks', linkScript]);
5455
child.on('close', function(code, signal) {
5556
assert(!code);
5657
assert(!signal);

0 commit comments

Comments
 (0)