10 lines
655 B
JavaScript
10 lines
655 B
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { LiveClient } from "../dist/index.js";
|
|
test("client dispatches a validated server event", () => {
|
|
const socket = {}; const client = new LiveClient({ url: "ws://invalid", websocketFactory: () => socket }); let received;
|
|
client.on("live.enter", event => { received = event; }); client.connect();
|
|
socket.onmessage({ data: JSON.stringify({ version: 1, id: "a0000000-0000-4000-8000-000000000001", occurredAt: new Date().toISOString(), roomId: "1", type: "live.enter", payload: { viewer: { uid: "1", name: "A" } } }) });
|
|
assert.equal(received.payload.viewer.name, "A");
|
|
});
|