1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-30 02:59:11 -05:00
denoland-deno/tests/unit_node/cluster_test.ts
Marvin Hagemeister 1dad29aa04
fix(node/cluster): improve stubs to make log4js work (#25146)
- Add missing exports to `node:cluster`
- Fix default export not being an instance of `EventEmitter`
- Fix aliasing of properties
- Fix `disconnected` -> `disconnect` export naming

This makes `log4js` work in Deno. `karma` starts too, but somehow the
server isn't responding. That looks like a different issue.

Fixes https://github.com/denoland/deno/issues/24858
2024-08-26 11:19:58 +02:00

43 lines
2 KiB
TypeScript

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "@std/assert";
import cluster from "node:cluster";
import * as clusterNamed from "node:cluster";
Deno.test("[node/cluster] has all node exports", () => {
assertEquals(cluster.isPrimary, true);
assertEquals(cluster.isMaster, true);
assertEquals(cluster.isWorker, false);
assertEquals(typeof cluster.disconnect, "function");
assertEquals(typeof cluster.on, "function");
assertEquals(cluster.workers, {});
assertEquals(cluster.settings, {});
assertEquals(cluster.SCHED_NONE, 1);
assertEquals(cluster.SCHED_RR, 2);
assertEquals(typeof cluster.fork, "function");
assertEquals(typeof cluster.disconnect, "function");
assertEquals(typeof cluster.setupPrimary, "function");
assertEquals(cluster.setupPrimary, cluster.setupMaster);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.setupPrimary, clusterNamed.setupPrimary);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.setupMaster, clusterNamed.setupMaster);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.workers, clusterNamed.workers);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.settings, clusterNamed.settings);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.fork, clusterNamed.fork);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.disconnect, clusterNamed.disconnect);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.SCHED_NONE, clusterNamed.SCHED_NONE);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.SCHED_RR, clusterNamed.SCHED_RR);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.isWorker, clusterNamed.isWorker);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.isPrimary, clusterNamed.isPrimary);
// @ts-ignore Our @types/node version is too old
assertEquals(cluster.isMaster, clusterNamed.isMaster);
});