node/test/parallel/test-cluster-worker-constructor.js
Adrian Estrada 81b0cc4475 test: improve test-cluster-worker-constructor.js
* use let and const instead of var
* use assert.strictEqual instead assert.equal

PR-URL: https://github.com/nodejs/node/pull/10396
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-23 10:40:52 -05:00

29 lines
795 B
JavaScript

'use strict';
// test-cluster-worker-constructor.js
// validates correct behavior of the cluster.Worker constructor
require('../common');
const assert = require('assert');
const cluster = require('cluster');
let worker;
worker = new cluster.Worker();
assert.strictEqual(worker.suicide, undefined);
assert.strictEqual(worker.state, 'none');
assert.strictEqual(worker.id, 0);
assert.strictEqual(worker.process, undefined);
worker = new cluster.Worker({
id: 3,
state: 'online',
process: process
});
assert.strictEqual(worker.suicide, undefined);
assert.strictEqual(worker.state, 'online');
assert.strictEqual(worker.id, 3);
assert.strictEqual(worker.process, process);
worker = cluster.Worker.call({}, {id: 5});
assert(worker instanceof cluster.Worker);
assert.strictEqual(worker.id, 5);