@signalwire/js 3.17.0-dev.202211101554.ff4eda6.0 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/src/BaseSession.d.ts +4 -1
- package/dist/core/src/BaseSession.d.ts.map +1 -1
- package/dist/core/src/redux/actions.d.ts +0 -2
- package/dist/core/src/redux/actions.d.ts.map +1 -1
- package/dist/core/src/redux/rootSaga.d.ts +0 -16
- package/dist/core/src/redux/rootSaga.d.ts.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/js/src/JWTSession.d.ts.map +1 -1
- package/dist/js/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/chat/Client.test.ts +34 -4
- package/src/createClient.test.ts +4 -0
- package/src/pubSub/Client.test.ts +13 -10
package/src/chat/Client.test.ts
CHANGED
|
@@ -134,6 +134,8 @@ describe('ChatClient Object', () => {
|
|
|
134
134
|
const connectMsg = JSON.parse(server.messages[0].toString())
|
|
135
135
|
expect(connectMsg.method).toBe('signalwire.connect')
|
|
136
136
|
expect(server.messages.length).toBe(3)
|
|
137
|
+
|
|
138
|
+
chat.disconnect()
|
|
137
139
|
})
|
|
138
140
|
|
|
139
141
|
it('should emit a single "signalwire.connect" at most when subscribing/publishing at the same time', async () => {
|
|
@@ -160,6 +162,8 @@ describe('ChatClient Object', () => {
|
|
|
160
162
|
return parsedMessage.method === 'signalwire.connect'
|
|
161
163
|
}).length
|
|
162
164
|
).toBe(1)
|
|
165
|
+
|
|
166
|
+
chat.disconnect()
|
|
163
167
|
})
|
|
164
168
|
|
|
165
169
|
describe('message handler', () => {
|
|
@@ -226,7 +230,9 @@ describe('ChatClient Object', () => {
|
|
|
226
230
|
|
|
227
231
|
done()
|
|
228
232
|
})
|
|
229
|
-
chat.subscribe(['test1'])
|
|
233
|
+
chat.subscribe(['test1']).then(() => {
|
|
234
|
+
chat.disconnect()
|
|
235
|
+
})
|
|
230
236
|
})
|
|
231
237
|
})
|
|
232
238
|
|
|
@@ -284,7 +290,9 @@ describe('ChatClient Object', () => {
|
|
|
284
290
|
done()
|
|
285
291
|
})
|
|
286
292
|
|
|
287
|
-
chat.subscribe(['test1'])
|
|
293
|
+
chat.subscribe(['test1']).then(() => {
|
|
294
|
+
chat.disconnect()
|
|
295
|
+
})
|
|
288
296
|
})
|
|
289
297
|
|
|
290
298
|
it('should return a ChatMember object on member.updated', (done) => {
|
|
@@ -324,7 +332,9 @@ describe('ChatClient Object', () => {
|
|
|
324
332
|
done()
|
|
325
333
|
})
|
|
326
334
|
|
|
327
|
-
chat.subscribe(['test1'])
|
|
335
|
+
chat.subscribe(['test1']).then(() => {
|
|
336
|
+
chat.disconnect()
|
|
337
|
+
})
|
|
328
338
|
})
|
|
329
339
|
|
|
330
340
|
it('should return a ChatMember object on member.left', (done) => {
|
|
@@ -360,7 +370,9 @@ describe('ChatClient Object', () => {
|
|
|
360
370
|
done()
|
|
361
371
|
})
|
|
362
372
|
|
|
363
|
-
chat.subscribe(['test1'])
|
|
373
|
+
chat.subscribe(['test1']).then(() => {
|
|
374
|
+
chat.disconnect()
|
|
375
|
+
})
|
|
364
376
|
})
|
|
365
377
|
})
|
|
366
378
|
|
|
@@ -380,6 +392,7 @@ describe('ChatClient Object', () => {
|
|
|
380
392
|
{ name: 'test2' },
|
|
381
393
|
{ name: 'test3' },
|
|
382
394
|
])
|
|
395
|
+
chat.disconnect()
|
|
383
396
|
})
|
|
384
397
|
})
|
|
385
398
|
|
|
@@ -407,6 +420,8 @@ describe('ChatClient Object', () => {
|
|
|
407
420
|
expect(parsedMessage.params).toStrictEqual(params)
|
|
408
421
|
}
|
|
409
422
|
})
|
|
423
|
+
|
|
424
|
+
chat.disconnect()
|
|
410
425
|
})
|
|
411
426
|
})
|
|
412
427
|
|
|
@@ -427,6 +442,8 @@ describe('ChatClient Object', () => {
|
|
|
427
442
|
{ name: 'test2' },
|
|
428
443
|
{ name: 'test3' },
|
|
429
444
|
])
|
|
445
|
+
|
|
446
|
+
chat.disconnect()
|
|
430
447
|
})
|
|
431
448
|
|
|
432
449
|
it('should allow the user to .unsubscribe() from any subgroup of subscribed channels', async () => {
|
|
@@ -445,6 +462,8 @@ describe('ChatClient Object', () => {
|
|
|
445
462
|
expect(
|
|
446
463
|
await chat.unsubscribe(['test1', 'test2', 'test3'])
|
|
447
464
|
).toBeUndefined()
|
|
465
|
+
|
|
466
|
+
chat.disconnect()
|
|
448
467
|
})
|
|
449
468
|
|
|
450
469
|
it('should reject if its called before the session is authorized', async () => {
|
|
@@ -463,6 +482,8 @@ describe('ChatClient Object', () => {
|
|
|
463
482
|
'You must be authenticated to unsubscribe from a channel'
|
|
464
483
|
)
|
|
465
484
|
}
|
|
485
|
+
|
|
486
|
+
chat.disconnect()
|
|
466
487
|
})
|
|
467
488
|
|
|
468
489
|
it("should reject if it's called without channels", async () => {
|
|
@@ -482,6 +503,8 @@ describe('ChatClient Object', () => {
|
|
|
482
503
|
})
|
|
483
504
|
|
|
484
505
|
await expect(() => chat.unsubscribe(['test1_error'])).rejects.toBeTruthy()
|
|
506
|
+
|
|
507
|
+
chat.disconnect()
|
|
485
508
|
})
|
|
486
509
|
|
|
487
510
|
it('should reject if the user calls .unsubscribe() with channels different than the ones they are subscribed to', async () => {
|
|
@@ -497,6 +520,8 @@ describe('ChatClient Object', () => {
|
|
|
497
520
|
await expect(() =>
|
|
498
521
|
chat.unsubscribe(['test1', 'test5_error'])
|
|
499
522
|
).rejects.toBeTruthy()
|
|
523
|
+
|
|
524
|
+
chat.disconnect()
|
|
500
525
|
})
|
|
501
526
|
})
|
|
502
527
|
|
|
@@ -522,6 +547,7 @@ describe('ChatClient Object', () => {
|
|
|
522
547
|
},
|
|
523
548
|
],
|
|
524
549
|
})
|
|
550
|
+
chat.disconnect()
|
|
525
551
|
})
|
|
526
552
|
})
|
|
527
553
|
|
|
@@ -560,6 +586,7 @@ describe('ChatClient Object', () => {
|
|
|
560
586
|
after: 'after',
|
|
561
587
|
},
|
|
562
588
|
})
|
|
589
|
+
chat.disconnect()
|
|
563
590
|
})
|
|
564
591
|
})
|
|
565
592
|
|
|
@@ -587,6 +614,7 @@ describe('ChatClient Object', () => {
|
|
|
587
614
|
})
|
|
588
615
|
|
|
589
616
|
expect(response).toStrictEqual(undefined)
|
|
617
|
+
chat.disconnect()
|
|
590
618
|
})
|
|
591
619
|
})
|
|
592
620
|
|
|
@@ -620,6 +648,7 @@ describe('ChatClient Object', () => {
|
|
|
620
648
|
},
|
|
621
649
|
},
|
|
622
650
|
})
|
|
651
|
+
chat.disconnect()
|
|
623
652
|
})
|
|
624
653
|
|
|
625
654
|
it('should send the proper RPC without (optional) channels', async () => {
|
|
@@ -649,6 +678,7 @@ describe('ChatClient Object', () => {
|
|
|
649
678
|
},
|
|
650
679
|
},
|
|
651
680
|
})
|
|
681
|
+
chat.disconnect()
|
|
652
682
|
})
|
|
653
683
|
})
|
|
654
684
|
})
|
package/src/createClient.test.ts
CHANGED
|
@@ -34,6 +34,7 @@ describe('createClient', () => {
|
|
|
34
34
|
error: authError,
|
|
35
35
|
})
|
|
36
36
|
)
|
|
37
|
+
return
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
socket.send(
|
|
@@ -65,6 +66,7 @@ describe('createClient', () => {
|
|
|
65
66
|
} catch (e) {
|
|
66
67
|
expect(e).toBeInstanceOf(AuthError)
|
|
67
68
|
}
|
|
69
|
+
client.disconnect()
|
|
68
70
|
})
|
|
69
71
|
|
|
70
72
|
it('should resolve `connect()` when the client is authorized', async () => {
|
|
@@ -81,6 +83,7 @@ describe('createClient', () => {
|
|
|
81
83
|
})
|
|
82
84
|
|
|
83
85
|
await client.connect()
|
|
86
|
+
client.disconnect()
|
|
84
87
|
})
|
|
85
88
|
|
|
86
89
|
it('should automatically resolve (without hitting the network) when calling `.connect()` if the session was already authorized', async () => {
|
|
@@ -112,5 +115,6 @@ describe('createClient', () => {
|
|
|
112
115
|
await Promise.all([client.connect(), client.connect(), client.connect()])
|
|
113
116
|
|
|
114
117
|
expect(messageHandler).toHaveBeenCalledTimes(1)
|
|
118
|
+
client.disconnect()
|
|
115
119
|
})
|
|
116
120
|
})
|
|
@@ -4,14 +4,6 @@ import { Client } from './Client'
|
|
|
4
4
|
describe('PubSubClient Object', () => {
|
|
5
5
|
const host = 'ws://localhost:1234'
|
|
6
6
|
const token = '<jwt>'
|
|
7
|
-
const messages = [
|
|
8
|
-
{
|
|
9
|
-
id: '5fdc8fc5-b7fe-4fbd-8204-f2310dec2614',
|
|
10
|
-
sender_id: '1507e5f9-075c-463d-94ba-a8f9ec0c7d4e',
|
|
11
|
-
content: 'hello world',
|
|
12
|
-
published_at: 1641393396.153,
|
|
13
|
-
},
|
|
14
|
-
]
|
|
15
7
|
|
|
16
8
|
let server: WS
|
|
17
9
|
beforeEach(async () => {
|
|
@@ -69,9 +61,9 @@ describe('PubSubClient Object', () => {
|
|
|
69
61
|
|
|
70
62
|
const connectMsg = JSON.parse(server.messages[0].toString())
|
|
71
63
|
expect(connectMsg.method).toBe('signalwire.connect')
|
|
72
|
-
console.log('server.messages--_>', server.messages);
|
|
73
64
|
|
|
74
65
|
expect(server.messages.length).toBe(3)
|
|
66
|
+
pubSub.disconnect()
|
|
75
67
|
})
|
|
76
68
|
|
|
77
69
|
it('should emit a single "signalwire.connect" at most when subscribing/publishing at the same time', async () => {
|
|
@@ -98,6 +90,7 @@ describe('PubSubClient Object', () => {
|
|
|
98
90
|
return parsedMessage.method === 'signalwire.connect'
|
|
99
91
|
}).length
|
|
100
92
|
).toBe(1)
|
|
93
|
+
pubSub.disconnect()
|
|
101
94
|
})
|
|
102
95
|
|
|
103
96
|
describe('Subscribe', () => {
|
|
@@ -116,6 +109,7 @@ describe('PubSubClient Object', () => {
|
|
|
116
109
|
{ name: 'test2' },
|
|
117
110
|
{ name: 'test3' },
|
|
118
111
|
])
|
|
112
|
+
pubSub.disconnect()
|
|
119
113
|
})
|
|
120
114
|
})
|
|
121
115
|
|
|
@@ -143,6 +137,8 @@ describe('PubSubClient Object', () => {
|
|
|
143
137
|
expect(parsedMessage.params).toStrictEqual(params)
|
|
144
138
|
}
|
|
145
139
|
})
|
|
140
|
+
|
|
141
|
+
pubSub.disconnect()
|
|
146
142
|
})
|
|
147
143
|
})
|
|
148
144
|
|
|
@@ -163,6 +159,7 @@ describe('PubSubClient Object', () => {
|
|
|
163
159
|
{ name: 'test2' },
|
|
164
160
|
{ name: 'test3' },
|
|
165
161
|
])
|
|
162
|
+
pubSub.disconnect()
|
|
166
163
|
})
|
|
167
164
|
|
|
168
165
|
it('should allow the user to .unsubscribe() from any subgroup of subscribed channels', async () => {
|
|
@@ -181,6 +178,7 @@ describe('PubSubClient Object', () => {
|
|
|
181
178
|
expect(
|
|
182
179
|
await pubSub.unsubscribe(['test1', 'test2', 'test3'])
|
|
183
180
|
).toBeUndefined()
|
|
181
|
+
pubSub.disconnect()
|
|
184
182
|
})
|
|
185
183
|
|
|
186
184
|
it('should reject if its called before the session is authorized', async () => {
|
|
@@ -199,6 +197,7 @@ describe('PubSubClient Object', () => {
|
|
|
199
197
|
'You must be authenticated to unsubscribe from a channel'
|
|
200
198
|
)
|
|
201
199
|
}
|
|
200
|
+
pubSub.disconnect()
|
|
202
201
|
})
|
|
203
202
|
|
|
204
203
|
it("should reject if it's called without channels", async () => {
|
|
@@ -217,7 +216,10 @@ describe('PubSubClient Object', () => {
|
|
|
217
216
|
content: 'test',
|
|
218
217
|
})
|
|
219
218
|
|
|
220
|
-
await expect(() =>
|
|
219
|
+
await expect(() =>
|
|
220
|
+
pubSub.unsubscribe(['test1_error'])
|
|
221
|
+
).rejects.toBeTruthy()
|
|
222
|
+
pubSub.disconnect()
|
|
221
223
|
})
|
|
222
224
|
|
|
223
225
|
it('should reject if the user calls .unsubscribe() with channels different than the ones they are subscribed to', async () => {
|
|
@@ -233,6 +235,7 @@ describe('PubSubClient Object', () => {
|
|
|
233
235
|
await expect(() =>
|
|
234
236
|
pubSub.unsubscribe(['test1', 'test5_error'])
|
|
235
237
|
).rejects.toBeTruthy()
|
|
238
|
+
pubSub.disconnect()
|
|
236
239
|
})
|
|
237
240
|
})
|
|
238
241
|
})
|