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: modernize JS and tighten equality checking #8602

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
22 changes: 11 additions & 11 deletions test/parallel/test-child-process-disconnect.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var fork = require('child_process').fork;
var net = require('net');
const assert = require('assert');
const fork = require('child_process').fork;
const net = require('net');

// child
if (process.argv[2] === 'child') {

// Check that the 'disconnect' event is deferred to the next event loop tick.
var disconnect = process.disconnect;
const disconnect = process.disconnect;
process.disconnect = function() {
disconnect.apply(this, arguments);
// If the event is emitted synchronously, we're too late by now.
Expand All @@ -17,7 +17,7 @@ if (process.argv[2] === 'child') {
function disconnectIsNotAsync() {}
};

var server = net.createServer();
const server = net.createServer();

server.on('connection', function(socket) {

Expand Down Expand Up @@ -45,10 +45,10 @@ if (process.argv[2] === 'child') {

} else {
// testcase
var child = fork(process.argv[1], ['child']);
const child = fork(process.argv[1], ['child']);

var childFlag = false;
var parentFlag = false;
let childFlag = false;
let parentFlag = false;

// when calling .disconnect the event should emit
// and the disconnected flag should be true.
Expand All @@ -64,7 +64,7 @@ if (process.argv[2] === 'child') {
if (obj && obj.msg === 'ready') {

// connect to child using TCP to know if disconnect was emitted
var socket = net.connect(obj.port);
const socket = net.connect(obj.port);

socket.on('data', function(data) {
data = data.toString();
Expand All @@ -84,7 +84,7 @@ if (process.argv[2] === 'child') {
});

process.on('exit', function() {
assert.equal(childFlag, false);
assert.equal(parentFlag, false);
assert.strictEqual(childFlag, false);
assert.strictEqual(parentFlag, false);
});
}