Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: cleanup/update test-os.js #8761

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/parallel/test-os.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ console.error(interfaces);
switch (platform) {
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can the filter be replaced with an arrow function, still within 80 chars limits?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arrow function will work in the linux part, but I don't believe it can (at least not in any obvious way) in the second instance (in the win32 portion) where the line it needs to be put into is longer. I'm reluctant to make them different from each other. Seems clearer to me to have them both be the same, even if it means an extra line in one case. Since the comment is labeled as a nit and ends with a question mark, I'm going to take that to mean that it's OK for this to land without that suggestion.

const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0',
mac: '00:00:00:00:00:00', family: 'IPv4',
Expand All @@ -111,7 +111,7 @@ switch (platform) {
}
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 expected = [{ address: '127.0.0.1', netmask: '255.0.0.0',
mac: '00:00:00:00:00:00', family: 'IPv4',
Expand All @@ -129,17 +129,17 @@ const home = os.homedir();

console.log('homedir = ' + home);
is.string(home);
assert.ok(home.indexOf(path.sep) !== -1);
assert.ok(home.includes(path.sep));

if (common.isWindows && process.env.USERPROFILE) {
assert.strictEqual(home, 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;
} else if (!common.isWindows && process.env.HOME) {
assert.strictEqual(home, 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;
}

Expand All @@ -157,13 +157,13 @@ if (common.isWindows) {
} else {
is.number(pwd.uid);
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.gid, pwdBuf.gid);
assert.strictEqual(pwd.shell, pwdBuf.shell.toString('utf8'));
}

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.homedir, pwdBuf.homedir.toString('utf8'));