Always show voice broadcasts tile (#9444)

This commit is contained in:
Michael Weimann 2022-10-19 12:04:15 +02:00 committed by GitHub
parent e0ab0ac5c9
commit 84f2974b57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 99 deletions

View file

@ -16,11 +16,9 @@ limitations under the License.
import React from "react";
import { render, RenderResult } from "@testing-library/react";
import { mocked } from "jest-mock";
import { MatrixClient, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
import { Features } from "../../../../src/settings/Settings";
import SettingsStore, { CallbackFn } from "../../../../src/settings/SettingsStore";
import SettingsStore from "../../../../src/settings/SettingsStore";
import { VoiceBroadcastInfoEventType, VoiceBroadcastInfoState } from "../../../../src/voice-broadcast";
import { mkEvent, mkRoom, stubClient } from "../../../test-utils";
import MessageEvent from "../../../../src/components/views/messages/MessageEvent";
@ -57,8 +55,7 @@ describe("MessageEvent", () => {
});
describe("when a voice broadcast start event occurs", () => {
const voiceBroadcastSettingWatcherRef = "vb ref";
let onVoiceBroadcastSettingChanged: CallbackFn;
let result: RenderResult;
beforeEach(() => {
event = mkEvent({
@ -70,64 +67,11 @@ describe("MessageEvent", () => {
state: VoiceBroadcastInfoState.Started,
},
});
mocked(SettingsStore.watchSetting).mockImplementation(
(settingName: string, roomId: string | null, callbackFn: CallbackFn) => {
if (settingName === Features.VoiceBroadcast) {
onVoiceBroadcastSettingChanged = callbackFn;
return voiceBroadcastSettingWatcherRef;
}
},
);
result = renderMessageEvent();
});
describe("and the voice broadcast feature is enabled", () => {
let result: RenderResult;
beforeEach(() => {
mocked(SettingsStore.getValue).mockImplementation((settingName: string) => {
return settingName === Features.VoiceBroadcast;
});
result = renderMessageEvent();
});
it("should render a VoiceBroadcast component", () => {
result.getByTestId("voice-broadcast-body");
});
describe("and switching the voice broadcast feature off", () => {
beforeEach(() => {
onVoiceBroadcastSettingChanged(Features.VoiceBroadcast, null, null, null, false);
});
it("should render an UnknownBody component", () => {
const result = renderMessageEvent();
result.getByTestId("unknown-body");
});
});
describe("and unmounted", () => {
beforeEach(() => {
result.unmount();
});
it("should unregister the settings watcher", () => {
expect(SettingsStore.unwatchSetting).toHaveBeenCalled();
});
});
});
describe("and the voice broadcast feature is disabled", () => {
beforeEach(() => {
mocked(SettingsStore.getValue).mockImplementation((settingName: string) => {
return false;
});
});
it("should render an UnknownBody component", () => {
const result = renderMessageEvent();
result.getByTestId("unknown-body");
});
it("should render a VoiceBroadcast component", () => {
result.getByTestId("voice-broadcast-body");
});
});
});