Something went wrong. Try again.
ouija board1
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132import assert from "node:assert/strict";import test from "node:test";
import { createInProcessEndpointPair } from "../dist/index.js";
test("in-process endpoints deliver messages to the opposite endpoint", () => { const { a, b } = createInProcessEndpointPair(); const receivedByA = []; const receivedByB = [];
a.subscribe((message) => receivedByA.push(message)); b.subscribe((message) => receivedByB.push(message));
a.send({ type: "patch", revision: 1 }); b.send({ type: "ack", revision: 1 });
assert.deepEqual(receivedByA, [{ type: "ack", revision: 1 }]); assert.deepEqual(receivedByB, [{ type: "patch", revision: 1 }]);});
test("in-process endpoint subscriptions can be removed", () => { const { a, b } = createInProcessEndpointPair(); const received = []; const unsubscribe = a.subscribe((message) => received.push(message));
b.send({ type: "first" }); unsubscribe(); b.send({ type: "second" });
assert.deepEqual(received, [{ type: "first" }]);});