UNPKG

@jjavery/worker-pool

Version:

A worker pool for Node.js applications

43 lines 1.42 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const worker_1 = __importDefault(require("./worker")); describe('Worker', function () { it('creates a worker', async function () { const worker = new worker_1.default(); chai_1.assert.instanceOf(worker, worker_1.default); }); it('starts a worker', async function () { const worker = new worker_1.default(); await worker.start(); try { chai_1.assert.isNumber(worker.pid); } catch (err) { throw err; } finally { await worker.stop(); } }); it('stops a worker', async function () { const worker = new worker_1.default(); await worker.start(); await worker.stop(); chai_1.assert.isNull(worker.pid); }); it('sends a request to a worker and receives a result', async function () { const worker = new worker_1.default(); await worker.start(); const result = await worker.request({ modulePath: 'os', functionName: 'hostname' }); await worker.stop(); chai_1.assert.isString(result); }); }); //# sourceMappingURL=worker.test.js.map