2022-10-20 16:41:10 +03:00
|
|
|
/*
|
2024-09-09 16:57:16 +03:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-10-20 16:41:10 +03:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 16:57:16 +03: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 16:41:10 +03:00
|
|
|
*/
|
|
|
|
|
2024-10-15 16:57:26 +03: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 16:41:10 +03:00
|
|
|
|
|
|
|
describe("getChunkLength", () => {
|
|
|
|
afterEach(() => {
|
2023-04-26 12:36:00 +03:00
|
|
|
SdkConfig.reset();
|
2022-10-20 16:41:10 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("when there is a value provided by Sdk config", () => {
|
|
|
|
beforeEach(() => {
|
2023-04-26 12:36:00 +03:00
|
|
|
SdkConfig.add({
|
|
|
|
voice_broadcast: {
|
|
|
|
chunk_length: 42,
|
|
|
|
},
|
|
|
|
});
|
2022-10-20 16:41:10 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should return this value", () => {
|
|
|
|
expect(getChunkLength()).toBe(42);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("when Sdk config does not provide a value", () => {
|
|
|
|
beforeEach(() => {
|
2023-04-26 12:36:00 +03:00
|
|
|
SdkConfig.add({
|
|
|
|
voice_broadcast: {
|
|
|
|
chunk_length: 23,
|
|
|
|
},
|
|
|
|
});
|
2022-10-20 16:41:10 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should return this value", () => {
|
|
|
|
expect(getChunkLength()).toBe(23);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-12-23 16:45:26 +03:00
|
|
|
describe("when there are no defaults", () => {
|
2022-10-20 16:41:10 +03:00
|
|
|
it("should return the fallback value", () => {
|
|
|
|
expect(getChunkLength()).toBe(120);
|
|
|
|
});
|
|
|
|
});
|
2022-12-23 16:45:26 +03: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 16:41:10 +03:00
|
|
|
});
|