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: refactor functions to es6 #23510

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
test: refactor functions to es6
  • Loading branch information
M1chaelChen committed Oct 12, 2018

Verified

This commit was signed with the committer’s verified signature. The key has expired.
addaleax Anna Henningsen
commit 5827c33fb2568d92e92ed08ff1cee2367c403b6e
14 changes: 6 additions & 8 deletions test/parallel/test-cluster-setup-master-multiple.js
Original file line number Diff line number Diff line change
@@ -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));
});
@@ -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);

@@ -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);