Skip to content

test: add tests for reconnect recovery #19

Description

@Aaromalpm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions