@@ -43,7 +43,7 @@ import { CustomTemplatesService } from '../custom-templates.service';
4343import { MessageInputConfigService } from './message-input-config.service' ;
4444import { MessageTextComponent } from '../message-text/message-text.component' ;
4545
46- fdescribe ( 'MessageInputComponent' , ( ) => {
46+ describe ( 'MessageInputComponent' , ( ) => {
4747 let nativeElement : HTMLElement ;
4848 let component : MessageInputComponent ;
4949 let fixture : ComponentFixture < MessageInputComponent > ;
@@ -58,6 +58,7 @@ fdescribe('MessageInputComponent', () => {
5858 let mockActiveParentMessageId$ : BehaviorSubject < string | undefined > ;
5959 let sendMessageSpy : jasmine . Spy ;
6060 let updateMessageSpy : jasmine . Spy ;
61+ let channelSwitchState$ : BehaviorSubject < 'start' | 'end' > ;
6162 let channel : Channel ;
6263 let user : UserResponse ;
6364 let attachmentService : {
@@ -127,6 +128,7 @@ fdescribe('MessageInputComponent', () => {
127128 ] ,
128129 } ,
129130 } ) ;
131+ channelSwitchState$ = new BehaviorSubject < 'start' | 'end' > ( 'end' ) ;
130132 TestBed . configureTestingModule ( {
131133 imports : [ TranslateModule . forRoot ( ) , StreamAvatarModule ] ,
132134 declarations : [
@@ -151,6 +153,7 @@ fdescribe('MessageInputComponent', () => {
151153 typingStarted : typingStartedSpy ,
152154 typingStopped : typingStoppedSpy ,
153155 latestMessageDateByUserByChannels$,
156+ channelSwitchState$ : channelSwitchState$ ,
154157 } ,
155158 } ,
156159 {
@@ -1152,7 +1155,7 @@ fdescribe('MessageInputComponent', () => {
11521155 expect ( queryVoiceRecorderButton ( ) ?. disabled ) . toBe ( true ) ;
11531156 } ) ;
11541157
1155- describe ( 'message draft output ' , ( ) => {
1158+ describe ( 'message draft change ' , ( ) => {
11561159 it ( 'should emit undefined when all message fields are cleared' , ( ) => {
11571160 // Parent id doesn't count here
11581161 component . mode = 'thread' ;
@@ -1325,14 +1328,21 @@ fdescribe('MessageInputComponent', () => {
13251328 } ) ;
13261329
13271330 it ( 'should not emit if active channel changes' , ( ) => {
1331+ mockMessageToQuote$ . next ( mockMessage ( ) ) ;
1332+
13281333 const messageDraftSpy = jasmine . createSpy ( ) ;
13291334 component . messageDraftChange . subscribe ( messageDraftSpy ) ;
13301335 queryTextarea ( ) ?. valueChange . next ( 'Hello' ) ;
1336+ fixture . detectChanges ( ) ;
1337+
13311338 messageDraftSpy . calls . reset ( ) ;
1339+ channelSwitchState$ . next ( 'start' ) ;
1340+ mockMessageToQuote$ . next ( undefined ) ;
13321341 mockActiveChannel$ . next ( {
13331342 ...mockActiveChannel$ . getValue ( ) ,
13341343 id : 'new-channel' ,
13351344 } as any as Channel ) ;
1345+ channelSwitchState$ . next ( 'end' ) ;
13361346 fixture . detectChanges ( ) ;
13371347
13381348 expect ( messageDraftSpy ) . not . toHaveBeenCalled ( ) ;
0 commit comments