Skip to content

Commit

Permalink
test: refactor functions to es6
Browse files Browse the repository at this point in the history
PR-URL: #23510
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
  • Loading branch information
M1chaelChen authored and jasnell committed Oct 17, 2018
1 parent b06113a commit 9e6c983
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions test/parallel/test-cluster-setup-master-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@ assert(cluster.isMaster);
// makes that unnecessary. This is to make the test less fragile if the
// implementation ever changes such that cluster.settings is mutated instead of
// replaced.
function cheapClone(obj) {
return JSON.parse(JSON.stringify(obj));
}
const cheapClone = (obj) => JSON.parse(JSON.stringify(obj));

const configs = [];

// Capture changes
cluster.on('setup', function() {
cluster.on('setup', () => {
console.log('"setup" emitted', cluster.settings);
configs.push(cheapClone(cluster.settings));
});
Expand All @@ -48,7 +46,7 @@ const execs = [
'node-next-3',
];

process.on('exit', function assertTests() {
process.on('exit', () => {
// Tests that "setup" is emitted for every call to setupMaster
assert.strictEqual(configs.length, execs.length);

Expand All @@ -58,14 +56,14 @@ process.on('exit', function assertTests() {
});

// Make changes to cluster settings
execs.forEach(function(v, i) {
setTimeout(function() {
execs.forEach((v, i) => {
setTimeout(() => {
cluster.setupMaster({ exec: v });
}, i * 100);
});

// cluster emits 'setup' asynchronously, so we must stay alive long
// enough for that to happen
setTimeout(function() {
setTimeout(() => {
console.log('cluster setup complete');
}, (execs.length + 1) * 100);

0 comments on commit 9e6c983

Please sign in to comment.