2022-10-20 13:41:10 +00:00
|
|
|
/*
|
2024-09-09 13:57:16 +00:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-10-20 13:41:10 +00:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 13:57:16 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-10-20 13:41:10 +00:00
|
|
|
*/
|
|
|
|
|
2024-10-15 13:57:26 +00:00
|
|
|
import SdkConfig from "../../../../src/SdkConfig";
|
|
|
|
import { SettingLevel } from "../../../../src/settings/SettingLevel";
|
|
|
|
import { Features } from "../../../../src/settings/Settings";
|
|
|
|
import SettingsStore from "../../../../src/settings/SettingsStore";
|
|
|
|
import { getChunkLength } from "../../../../src/voice-broadcast/utils/getChunkLength";
|
2022-10-20 13:41:10 +00:00
|
|
|
|
|
|
|
describe("getChunkLength", () => {
|
|
|
|
afterEach(() => {
|
2023-04-26 09:36:00 +00:00
|
|
|
SdkConfig.reset();
|
2022-10-20 13:41:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("when there is a value provided by Sdk config", () => {
|
|
|
|
beforeEach(() => {
|
2023-04-26 09:36:00 +00:00
|
|
|
SdkConfig.add({
|
|
|
|
voice_broadcast: {
|
|
|
|
chunk_length: 42,
|
|
|
|
},
|
|
|
|
});
|
2022-10-20 13:41:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should return this value", () => {
|
|
|
|
expect(getChunkLength()).toBe(42);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("when Sdk config does not provide a value", () => {
|
|
|
|
beforeEach(() => {
|
2023-04-26 09:36:00 +00:00
|
|
|
SdkConfig.add({
|
|
|
|
voice_broadcast: {
|
|
|
|
chunk_length: 23,
|
|
|
|
},
|
|
|
|
});
|
2022-10-20 13:41:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should return this value", () => {
|
|
|
|
expect(getChunkLength()).toBe(23);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-12-23 13:45:26 +00:00
|
|
|
describe("when there are no defaults", () => {
|
2022-10-20 13:41:10 +00:00
|
|
|
it("should return the fallback value", () => {
|
|
|
|
expect(getChunkLength()).toBe(120);
|
|
|
|
});
|
|
|
|
});
|
2022-12-23 13:45:26 +00:00
|
|
|
|
|
|
|
describe("when the Features.VoiceBroadcastForceSmallChunks is enabled", () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
await SettingsStore.setValue(Features.VoiceBroadcastForceSmallChunks, null, SettingLevel.DEVICE, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return a chunk length of 15 seconds", () => {
|
|
|
|
expect(getChunkLength()).toBe(15);
|
|
|
|
});
|
|
|
|
});
|
2022-10-20 13:41:10 +00:00
|
|
|
});
|