Skip to content

Commit 78c46a0

Browse files
committed
test: add multiple clients test
1 parent c253633 commit 78c46a0

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/core/ws/WebSocketClientManager.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ it('adds a client from this runtime to the list of clients', () => {
3838
expect(Array.from(manager.clients.values())).toEqual([connection])
3939
})
4040

41+
it('adds multiple clients from this runtime to the list of clients', () => {
42+
const manager = new WebSocketClientManager(channel, '*')
43+
const connectionOne = new WebSocketClientConnection(
44+
socket,
45+
new TestWebSocketTransport(),
46+
)
47+
manager.addConnection(connectionOne)
48+
49+
// Must add the client to the list of clients.
50+
expect(Array.from(manager.clients.values())).toEqual([connectionOne])
51+
52+
const connectionTwo = new WebSocketClientConnection(
53+
socket,
54+
new TestWebSocketTransport(),
55+
)
56+
manager.addConnection(connectionTwo)
57+
58+
// Must add the new cilent to the list as well.
59+
expect(Array.from(manager.clients.values())).toEqual([
60+
connectionOne,
61+
connectionTwo,
62+
])
63+
})
64+
4165
it('replays a "send" event coming from another runtime', async () => {
4266
const manager = new WebSocketClientManager(channel, '*')
4367
const connection = new WebSocketClientConnection(

0 commit comments

Comments
 (0)