release: WRNexusJS 0.8.3
This commit is contained in:
@@ -121,3 +121,27 @@ test("programmatic wire.room() sends and receives", () => {
|
||||
sockets[0]!.fireMessage({ type: "ping", n: 1 });
|
||||
expect(got).toEqual([{ type: "ping", n: 1 }]);
|
||||
});
|
||||
|
||||
test("same room with different users opens identity-specific sockets", () => {
|
||||
boot(`
|
||||
<div data-room="teamspace" data-room-user="asha"></div>
|
||||
<div data-room="teamspace" data-room-user="rohan"></div>
|
||||
`);
|
||||
expect(sockets.map((socket) => socket.url).sort()).toEqual([
|
||||
"ws://localhost/realtime/teamspace?user=asha",
|
||||
"ws://localhost/realtime/teamspace?user=rohan",
|
||||
]);
|
||||
});
|
||||
|
||||
test("declarative room reconnects when its user identity changes", () => {
|
||||
const win = boot(
|
||||
`<div id="room" data-room="teamspace" data-room-user="asha"></div>`,
|
||||
) as unknown as Window & {
|
||||
wire: { bindRooms: (root?: unknown) => void };
|
||||
};
|
||||
expect(sockets[0]?.url).toBe("ws://localhost/realtime/teamspace?user=asha");
|
||||
win.document.getElementById("room")!.setAttribute("data-room-user", "neha");
|
||||
win.wire.bindRooms(win.document);
|
||||
expect(sockets[0]?.readyState).toBe(3);
|
||||
expect(sockets[1]?.url).toBe("ws://localhost/realtime/teamspace?user=neha");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user