|
1 | 1 | /// <reference types='jasmine' />
|
2 | 2 | /* tslint:disable:one-variable-per-declaration */
|
3 | 3 | import { SignalingState, WebGroup, WebGroupState } from '../../src/index.browser'
|
4 |
| -import { areTheSame, cleanWebGroup, IMessages, Queue, SIGNALING_URL, wait } from '../util/helper' |
| 4 | +import { |
| 5 | + areTheSame, |
| 6 | + cleanWebGroup, |
| 7 | + IMessages, |
| 8 | + Queue, |
| 9 | + randomBigArrayBuffer, |
| 10 | + SIGNALING_URL, |
| 11 | + wait, |
| 12 | +} from '../util/helper' |
5 | 13 |
|
6 | 14 | const WebGroupOptions = {
|
7 | 15 | signalingServer: SIGNALING_URL,
|
@@ -343,6 +351,37 @@ describe('🙂 🙂 🙂 - 3 clients', () => {
|
343 | 351 | wg3.send(msg3)
|
344 | 352 | })
|
345 | 353 |
|
| 354 | + /** @test {WebGroup#sendTo} */ |
| 355 | + it('broadcast message cutted in chunks (> 15kb)', (done) => { |
| 356 | + const bytes = randomBigArrayBuffer() |
| 357 | + const queue = new Queue(2, () => { |
| 358 | + wait(1000).then(() => { |
| 359 | + expect(called2).toEqual(1) |
| 360 | + expect(called3).toEqual(1) |
| 361 | + done() |
| 362 | + }) |
| 363 | + }) |
| 364 | + |
| 365 | + // Code for peer 2 |
| 366 | + wg2.onMessage = (id, msg) => { |
| 367 | + expect(msg instanceof Uint8Array).toBeTruthy() |
| 368 | + expect(msg).toEqual(bytes) |
| 369 | + called2++ |
| 370 | + queue.done() |
| 371 | + } |
| 372 | + |
| 373 | + // Code for peer 3 |
| 374 | + wg3.onMessage = (id, msg) => { |
| 375 | + expect(msg instanceof Uint8Array).toBeTruthy() |
| 376 | + expect(msg).toEqual(bytes) |
| 377 | + called3++ |
| 378 | + queue.done() |
| 379 | + } |
| 380 | + |
| 381 | + // Start sending message |
| 382 | + wg1.send(bytes) |
| 383 | + }) |
| 384 | + |
346 | 385 | /** @test {WebGroup#sendTo} */
|
347 | 386 | it('private String', (done) => {
|
348 | 387 | const queue = new Queue(6, () => {
|
|
0 commit comments