Skip to content

Commit

Permalink
test: cleanup test-child-process-disconnect.js
Browse files Browse the repository at this point in the history
Changed var --> const and let
Changed assert.equal --> assert.strictEqual

PR-URL: #8602
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
  • Loading branch information
wzoom authored and Fishrock123 committed Oct 11, 2016
1 parent 9032ba6 commit 14025db
Showing 1 changed file with 11 additions and 11 deletions.
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);
});
}

0 comments on commit 14025db

Please sign in to comment.