@@ -398,4 +398,52 @@ test.group('Transmit', () => {
398398
399399 assert . isTrue ( dataReceived )
400400 } )
401+
402+ test ( 'should return all subscribers for a channel' , async ( { assert } ) => {
403+ const transport = makeTransport ( )
404+ const transmit = makeTransmitWithTransport ( transport )
405+
406+ const stream1 = makeStream ( transmit )
407+ const stream2 = makeStream ( transmit )
408+ const stream3 = makeStream ( transmit )
409+ const stream4 = makeStream ( transmit )
410+ const stream5 = makeStream ( transmit )
411+
412+ await transmit . subscribe ( {
413+ uid : stream1 . getUid ( ) ,
414+ channel : 'channel1' ,
415+ } )
416+
417+ await transmit . subscribe ( {
418+ uid : stream2 . getUid ( ) ,
419+ channel : 'channel1' ,
420+ } )
421+
422+ await transmit . subscribe ( {
423+ uid : stream3 . getUid ( ) ,
424+ channel : 'channel2' ,
425+ } )
426+
427+ await transmit . subscribe ( {
428+ uid : stream4 . getUid ( ) ,
429+ channel : 'channel2' ,
430+ } )
431+
432+ await transmit . subscribe ( {
433+ uid : stream5 . getUid ( ) ,
434+ channel : 'channel2' ,
435+ } )
436+
437+ const uuidsChannel1 = transmit . getSubscribersFor ( 'channel1' )
438+ const uuidsChannel2 = transmit . getSubscribersFor ( 'channel2' )
439+
440+ assert . lengthOf ( uuidsChannel1 , 2 )
441+ assert . equal ( uuidsChannel1 [ 0 ] , stream1 . getUid ( ) )
442+ assert . equal ( uuidsChannel1 [ 1 ] , stream2 . getUid ( ) )
443+
444+ assert . lengthOf ( uuidsChannel2 , 3 )
445+ assert . equal ( uuidsChannel2 [ 0 ] , stream3 . getUid ( ) )
446+ assert . equal ( uuidsChannel2 [ 1 ] , stream4 . getUid ( ) )
447+ assert . equal ( uuidsChannel2 [ 2 ] , stream5 . getUid ( ) )
448+ } )
401449} )
0 commit comments