Skip to content

Commit ecd74a6

Browse files
committed
Fix tests
1 parent 9f9a678 commit ecd74a6

File tree

8 files changed

+29
-4
lines changed

8 files changed

+29
-4
lines changed

projects/stream-chat-angular/src/lib/channel.service.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,7 @@ describe('ChannelService', () => {
12461246
quoted_message_id: quotedMessageId,
12471247
isVote: true,
12481248
options: ['A', 'B', 'C'],
1249+
poll_id: undefined,
12491250
});
12501251

12511252
expect(channel.state.addMessageSorted).toHaveBeenCalledWith(
@@ -1284,6 +1285,7 @@ describe('ChannelService', () => {
12841285
quoted_message_id: undefined,
12851286
// @ts-expect-error testing custom proerpty
12861287
custom: 'red',
1288+
poll_id: undefined,
12871289
});
12881290

12891291
expect(channel.state.addMessageSorted).toHaveBeenCalledWith(
@@ -1304,6 +1306,7 @@ describe('ChannelService', () => {
13041306
id: jasmine.any(String),
13051307
parent_id: undefined,
13061308
quoted_message_id: undefined,
1309+
poll_id: undefined,
13071310
});
13081311

13091312
expect(channel.state.addMessageSorted).toHaveBeenCalledWith(

projects/stream-chat-angular/src/lib/channel.service.thread.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ describe('ChannelService - threads', () => {
558558
parent_id: 'parentId',
559559
quoted_message_id: undefined,
560560
...customData,
561+
poll_id: undefined,
561562
});
562563

563564
expect(channel.state.addMessageSorted).toHaveBeenCalledWith(

projects/stream-chat-angular/src/lib/channel.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@ export class ChannelService {
831831
* @param parentId Id of the parent message (if sending a thread reply)
832832
* @param quotedMessageId Id of the message to quote (if sending a quote reply)
833833
* @param customData
834+
* @param pollId Id of the poll (if sending a poll message)
834835
*/
835836
async sendMessage(
836837
text: string,

projects/stream-chat-angular/src/lib/message-input/message-input.component.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ describe('MessageInputComponent', () => {
307307
[],
308308
mentionedUsers,
309309
undefined,
310+
undefined,
311+
undefined,
310312
undefined
311313
);
312314

@@ -486,6 +488,8 @@ describe('MessageInputComponent', () => {
486488
attachments,
487489
[],
488490
undefined,
491+
undefined,
492+
undefined,
489493
undefined
490494
);
491495
});
@@ -589,6 +593,8 @@ describe('MessageInputComponent', () => {
589593
jasmine.any(Array),
590594
jasmine.any(Object),
591595
undefined,
596+
undefined,
597+
undefined,
592598
undefined
593599
);
594600
});
@@ -627,6 +633,8 @@ describe('MessageInputComponent', () => {
627633
undefined,
628634
[],
629635
undefined,
636+
undefined,
637+
undefined,
630638
undefined
631639
);
632640
});
@@ -709,7 +717,9 @@ describe('MessageInputComponent', () => {
709717
[],
710718
[],
711719
'parent message',
712-
'message-to-quote'
720+
'message-to-quote',
721+
undefined,
722+
undefined
713723
);
714724

715725
expect(typingStoppedSpy).toHaveBeenCalledWith('parent message');

projects/stream-chat-angular/src/lib/message-input/message-input.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ export class MessageInputComponent
534534
addPoll = (pollId: string) => {
535535
this.isComposerOpen = false;
536536
this.pollId = pollId;
537-
this.messageSent();
537+
void this.messageSent();
538538
};
539539

540540
async voiceRecordingReady(recording: AudioRecording) {

projects/stream-chat-angular/src/lib/polls/poll-composer/poll-composer.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@
8181
<ng-container formArrayName="options">
8282
<div class="str-chat__form__input-fieldset__values">
8383
<ng-container
84-
*ngFor="let option of options.controls; let i = index"
84+
*ngFor="
85+
let option of options.controls;
86+
let i = index;
87+
trackBy: trackByOptionValue
88+
"
8589
>
8690
<div class="str-chat__drag-and-drop-container__item">
8791
<div class="str-chat__form__input-field">

projects/stream-chat-angular/src/lib/polls/poll-composer/poll-composer.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,18 @@ export class PollComposerComponent {
112112
};
113113
}
114114

115+
trackByOptionValue(_: number, option: FormControl<string | null>) {
116+
return option.value;
117+
}
118+
115119
async createPoll() {
116120
try {
117121
const maxVotesControl = this.formGroup.get('maximum_number_of_votes');
118122
const response = await this.chatService.chatClient.polls.createPoll({
119123
name: this.formGroup.get('name')!.value!,
120124
options: this.formGroup
121125
.get('options')!
122-
.value!.filter((v) => !!v)
126+
.value.filter((v) => !!v)
123127
.map((v) => ({ text: v! })),
124128
enforce_unique_vote: !this.formGroup.get('multiple_answers')?.value,
125129
max_votes_allowed: maxVotesControl?.value

projects/stream-chat-angular/src/lib/polls/poll-composer/validators.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from '@angular/forms';
77

88
export function atLeastOneOption(): ValidatorFn {
9+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
910
return (control: AbstractControl<any, any>) => {
1011
const formArray = control as FormArray<FormControl<string | null>>;
1112
const hasAtLeastOne = formArray.value.some((item) => !!item);
@@ -16,6 +17,7 @@ export function atLeastOneOption(): ValidatorFn {
1617
export function maximumNumberOfVotes(
1718
canHaveMultipleVotes: FormControl<boolean>
1819
): ValidatorFn {
20+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1921
return (control: AbstractControl<any, any>) => {
2022
const formControl = control as FormControl<number | null>;
2123
return canHaveMultipleVotes.value && !formControl.value

0 commit comments

Comments
 (0)