Update session test mocks to use WsData type

Change mock websocket objects in session tests to include both room
and client fields, matching the WsData interface definition.
This commit is contained in:
Jared Miller 2026-01-27 21:04:54 -05:00
parent 00c9a140c6
commit 4b4b434bf8
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -1,6 +1,6 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import * as Y from "yjs"; import * as Y from "yjs";
import { getOrCreateSession, Session } from "./session"; import { type WsData, getOrCreateSession, Session } from "./session";
describe("Session", () => { describe("Session", () => {
test("creates yjs doc on init", () => { test("creates yjs doc on init", () => {
@ -13,8 +13,8 @@ describe("Session", () => {
const session = new Session("test-room"); const session = new Session("test-room");
const mockWs = { const mockWs = {
send: () => {}, send: () => {},
data: { room: null as string | null }, data: { room: null as string | null, client: null },
} as unknown as import("bun").ServerWebSocket<{ room: string | null }>; } as unknown as import("bun").ServerWebSocket<WsData>;
const client = { ws: mockWs }; const client = { ws: mockWs };
expect(session.clients.size).toBe(0); expect(session.clients.size).toBe(0);
@ -36,8 +36,8 @@ describe("Session", () => {
const mockWs = { const mockWs = {
send: () => {}, send: () => {},
data: { room: null as string | null }, data: { room: null as string | null, client: null },
} as unknown as import("bun").ServerWebSocket<{ room: string | null }>; } as unknown as import("bun").ServerWebSocket<WsData>;
session.applyUpdate(update, { ws: mockWs }); session.applyUpdate(update, { ws: mockWs });
expect(text.toString()).toBe("hello"); expect(text.toString()).toBe("hello");