Context
src/reconnect.js was added in #14 but has no tests.
What to test
rejoinRooms(socket, userId) — re-joins all rooms the user was previously in
rejoinRooms with since option — returns messages sent after the timestamp
rejoinRooms with since option — does NOT return messages sent before the timestamp
rejoinRooms for a userId with no tracked rooms — returns { rooms: [], missedMessages: {} }
rejoinRooms throws if userId is not provided
getUserRooms(userId) — returns correct room list after joinRoom calls
getUserRooms — room is removed from list after leaveRoom
getUserRooms — room is removed from list after closeRoom
trackUserRoom — silently skips if userId is undefined (no crash)
Setup tip
Use socket.io-client with a real server. Simulate disconnect/reconnect by disconnecting the client socket and connecting a new one with the same userId.
Context
src/reconnect.jswas added in #14 but has no tests.What to test
rejoinRooms(socket, userId)— re-joins all rooms the user was previously inrejoinRoomswithsinceoption — returns messages sent after the timestamprejoinRoomswithsinceoption — does NOT return messages sent before the timestamprejoinRoomsfor a userId with no tracked rooms — returns{ rooms: [], missedMessages: {} }rejoinRoomsthrows ifuserIdis not providedgetUserRooms(userId)— returns correct room list afterjoinRoomcallsgetUserRooms— room is removed from list afterleaveRoomgetUserRooms— room is removed from list aftercloseRoomtrackUserRoom— silently skips ifuserIdis undefined (no crash)Setup tip
Use
socket.io-clientwith a real server. Simulate disconnect/reconnect by disconnecting the client socket and connecting a new one with the same userId.