Browse Source

test: cleanup/update test-os.js

Replaced `==` with `===
Replaced `indexOf(...) !== -1` with `includes()`

PR-URL: https://github.com/nodejs/node/pull/8761
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
v6
Mike Woods 8 years ago
committed by Rich Trott
parent
commit
f5d997c476
  1. 14
      test/parallel/test-os.js

14
test/parallel/test-os.js

@ -101,7 +101,7 @@ console.error(interfaces);
switch (platform) { switch (platform) {
case 'linux': case 'linux':
{ {
const filter = function(e) { return e.address == '127.0.0.1'; }; const filter = function(e) { return e.address === '127.0.0.1'; };
const actual = interfaces.lo.filter(filter); const actual = interfaces.lo.filter(filter);
const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0', const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0',
mac: '00:00:00:00:00:00', family: 'IPv4', mac: '00:00:00:00:00:00', family: 'IPv4',
@ -111,7 +111,7 @@ switch (platform) {
} }
case 'win32': case 'win32':
{ {
const filter = function(e) { return e.address == '127.0.0.1'; }; const filter = function(e) { return e.address === '127.0.0.1'; };
const actual = interfaces['Loopback Pseudo-Interface 1'].filter(filter); const actual = interfaces['Loopback Pseudo-Interface 1'].filter(filter);
const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0', const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0',
mac: '00:00:00:00:00:00', family: 'IPv4', mac: '00:00:00:00:00:00', family: 'IPv4',
@ -129,17 +129,17 @@ const home = os.homedir();
console.log('homedir = ' + home); console.log('homedir = ' + home);
is.string(home); is.string(home);
assert.ok(home.indexOf(path.sep) !== -1); assert.ok(home.includes(path.sep));
if (common.isWindows && process.env.USERPROFILE) { if (common.isWindows && process.env.USERPROFILE) {
assert.strictEqual(home, process.env.USERPROFILE); assert.strictEqual(home, process.env.USERPROFILE);
delete process.env.USERPROFILE; delete process.env.USERPROFILE;
assert.ok(os.homedir().indexOf(path.sep) !== -1); assert.ok(os.homedir().includes(path.sep));
process.env.USERPROFILE = home; process.env.USERPROFILE = home;
} else if (!common.isWindows && process.env.HOME) { } else if (!common.isWindows && process.env.HOME) {
assert.strictEqual(home, process.env.HOME); assert.strictEqual(home, process.env.HOME);
delete process.env.HOME; delete process.env.HOME;
assert.ok(os.homedir().indexOf(path.sep) !== -1); assert.ok(os.homedir().includes(path.sep));
process.env.HOME = home; process.env.HOME = home;
} }
@ -157,13 +157,13 @@ if (common.isWindows) {
} else { } else {
is.number(pwd.uid); is.number(pwd.uid);
is.number(pwd.gid); is.number(pwd.gid);
assert.notStrictEqual(pwd.shell.indexOf(path.sep), -1); assert.ok(pwd.shell.includes(path.sep));
assert.strictEqual(pwd.uid, pwdBuf.uid); assert.strictEqual(pwd.uid, pwdBuf.uid);
assert.strictEqual(pwd.gid, pwdBuf.gid); assert.strictEqual(pwd.gid, pwdBuf.gid);
assert.strictEqual(pwd.shell, pwdBuf.shell.toString('utf8')); assert.strictEqual(pwd.shell, pwdBuf.shell.toString('utf8'));
} }
is.string(pwd.username); is.string(pwd.username);
assert.notStrictEqual(pwd.homedir.indexOf(path.sep), -1); assert.ok(pwd.homedir.includes(path.sep));
assert.strictEqual(pwd.username, pwdBuf.username.toString('utf8')); assert.strictEqual(pwd.username, pwdBuf.username.toString('utf8'));
assert.strictEqual(pwd.homedir, pwdBuf.homedir.toString('utf8')); assert.strictEqual(pwd.homedir, pwdBuf.homedir.toString('utf8'));

Loading…
Cancel
Save