1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00
Files
matrix-js-sdk/spec/unit/webrtc/stats/statsReportEmitter.spec.ts
Enrico Schwendig 0b396c005c indicator whether call members send media. (#3241)
* stats: add summery stats reporter

* stats: export summery stats reports

* stats: fix typo of event name

* stats: check promise condition for node 16 test linter

* stats: remove weak test to figure out memory leak

* stats: remove second weak test

* stats: add starting processing test

* stats: fix tests

* stats: fix typo in group call

* stats: fix stats report gathering test

* stats: reactivate promise merge

* stats: fix PR issues

---------

Co-authored-by: David Baker <dbkr@users.noreply.github.com>
2023-04-05 06:48:12 +00:00

66 lines
2.1 KiB
TypeScript

/*
Copyright 2023 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { StatsReportEmitter } from "../../../../src/webrtc/stats/statsReportEmitter";
import {
ByteSentStatsReport,
ConnectionStatsReport,
StatsReport,
SummaryStatsReport,
} from "../../../../src/webrtc/stats/statsReport";
describe("StatsReportEmitter", () => {
let emitter: StatsReportEmitter;
beforeEach(() => {
emitter = new StatsReportEmitter();
});
it("should emit and receive ByteSendStatsReport", async () => {
const report = {} as ByteSentStatsReport;
return new Promise((resolve, _) => {
emitter.on(StatsReport.BYTE_SENT_STATS, (r) => {
expect(r).toBe(report);
resolve(null);
return;
});
emitter.emitByteSendReport(report);
});
});
it("should emit and receive ConnectionStatsReport", async () => {
const report = {} as ConnectionStatsReport;
return new Promise((resolve, _) => {
emitter.on(StatsReport.CONNECTION_STATS, (r) => {
expect(r).toBe(report);
resolve(null);
return;
});
emitter.emitConnectionStatsReport(report);
});
});
it("should emit and receive SummaryStatsReport", async () => {
const report = {} as SummaryStatsReport;
return new Promise((resolve, _) => {
emitter.on(StatsReport.SUMMARY_STATS, (r) => {
expect(r).toBe(report);
resolve(null);
return;
});
emitter.emitSummaryStatsReport(report);
});
});
});