1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Make test pass

Don't send events all the way via the mock HTTP backend: we're not
trying to test that here. This meant we weren't actually getting
into the right state because the request to send the invite never
actually returned. Now this works, we need to clear the invite timer
otherwise jest has a timer hanging around at the end of the test
(plus we should be doing it anyway).
This commit is contained in:
David Baker
2020-10-21 12:41:36 +01:00
parent 8712703f7c
commit 30a01e26de
2 changed files with 26 additions and 8 deletions

View File

@@ -236,6 +236,7 @@ export class MatrixCall extends EventEmitter {
// The party ID of the other side: undefined if we haven't chosen a partner
// yet, null if we have but they didn't send a party ID.
private opponentPartyId: string;
private inviteTimeout;
constructor(opts: CallOpts) {
super();
@@ -941,7 +942,8 @@ export class MatrixCall extends EventEmitter {
try {
await this.sendVoipEvent(EventType.CallInvite, content);
this.setState(CallState.InviteSent);
setTimeout(() => {
this.inviteTimeout = setTimeout(() => {
this.inviteTimeout = null;
if (this.state === CallState.InviteSent) {
this.hangup(CallErrorCode.InviteTimeout, false);
}
@@ -1165,6 +1167,11 @@ export class MatrixCall extends EventEmitter {
private terminate(hangupParty: CallParty, hangupReason: CallErrorCode, shouldEmit: boolean) {
if (this.state === CallState.Ended) return;
if (this.inviteTimeout) {
clearTimeout(this.inviteTimeout);
this.inviteTimeout = null;
}
const remoteVid = this.getRemoteVideoElement();
const remoteAud = this.getRemoteAudioElement();
const localVid = this.getLocalVideoElement();