@@ -1524,6 +1524,7 @@ describe('ChannelService', () => {
15241524 it ( 'should query members, less than 100 members' , async ( ) => {
15251525 await init ( ) ;
15261526 const channel = generateMockChannels ( 1 ) [ 0 ] ;
1527+ channel . cid = 'new-channel' ;
15271528 channel . state . members = {
15281529 jack : { user : { id : 'jack' , name : 'Jack' } } ,
15291530 john : { user : { id : 'john' } } ,
@@ -1545,6 +1546,7 @@ describe('ChannelService', () => {
15451546 it ( 'should query members, more than 100 members' , async ( ) => {
15461547 await init ( ) ;
15471548 const channel = generateMockChannels ( 1 ) [ 0 ] ;
1549+ channel . cid = 'new-channel' ;
15481550 spyOn ( channel , 'queryMembers' ) . and . callThrough ( ) ;
15491551 const users = Array . from ( { length : 101 } , ( _ , i ) => ( { id : `${ i } ` } ) ) ;
15501552 channel . state . members = { } as any as Record <
@@ -1964,4 +1966,17 @@ describe('ChannelService', () => {
19641966 newChannel
19651967 ) ;
19661968 } ) ;
1969+
1970+ it ( 'should do nothing if same channel is selected twice' , ( ) => {
1971+ const activeChannel = generateMockChannels ( ) [ 0 ] ;
1972+
1973+ service . setAsActiveChannel ( activeChannel ) ;
1974+
1975+ const spy = jasmine . createSpy ( ) ;
1976+ service . activeChannel$ . subscribe ( spy ) ;
1977+ spy . calls . reset ( ) ;
1978+ service . setAsActiveChannel ( activeChannel ) ;
1979+
1980+ expect ( spy ) . not . toHaveBeenCalled ( ) ;
1981+ } ) ;
19671982} ) ;
0 commit comments