Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 69ea34e

Browse files
committed
test: check for roomprops
1 parent 20558ff commit 69ea34e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

test/components/views/settings/tabs/room/NotificationSettingsTab-test.tsx

+14-8
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ limitations under the License.
1515
*/
1616

1717
import React from "react";
18-
import { fireEvent, render, RenderResult } from "@testing-library/react";
18+
import { render, RenderResult } from "@testing-library/react";
1919
import { MatrixClient } from "matrix-js-sdk/src/client";
20+
import userEvent from "@testing-library/user-event";
2021

2122
import NotificationSettingsTab from "../../../../../../src/components/views/settings/tabs/room/NotificationSettingsTab";
2223
import { mkStubRoom, stubClient } from "../../../../../test-utils";
2324
import { MatrixClientPeg } from "../../../../../../src/MatrixClientPeg";
25+
import { EchoChamber } from "../../../../../../src/stores/local-echo/EchoChamber";
26+
import { RoomEchoChamber } from "../../../../../../src/stores/local-echo/RoomEchoChamber";
2427

2528
describe("NotificatinSettingsTab", () => {
2629
const roomId = "!room:example.com";
2730
let cli: MatrixClient;
31+
let roomProps: RoomEchoChamber;
2832

2933
const renderTab = (): RenderResult => {
3034
return render(<NotificationSettingsTab roomId={roomId} closeSettingsFn={() => { }} />);
@@ -33,20 +37,22 @@ describe("NotificatinSettingsTab", () => {
3337
beforeEach(() => {
3438
stubClient();
3539
cli = MatrixClientPeg.get();
36-
mkStubRoom(roomId, "test room", cli);
40+
const room = mkStubRoom(roomId, "test room", cli);
41+
roomProps = EchoChamber.forRoom(room);
3742

3843
NotificationSettingsTab.contextType = React.createContext(cli);
3944
});
4045

41-
it("should prevent »Settings« link click from bubbling up to radio buttons", () => {
46+
it("should prevent »Settings« link click from bubbling up to radio buttons", async () => {
4247
const tab = renderTab();
43-
const event = new MouseEvent("click", { bubbles: true });
44-
Object.assign(event, { preventDefault: jest.fn() });
4548

46-
const settingsLink = tab.container.querySelector("div.mx_AccessibleButton");
49+
// settings link of mentions_only volume
50+
const settingsLink = tab.container.querySelector(
51+
"label.mx_NotificationSettingsTab_mentionsKeywordsEntry div.mx_AccessibleButton");
4752
if (!settingsLink) throw new Error("settings link does not exist.");
4853

49-
fireEvent(settingsLink, event);
50-
expect(event.preventDefault).toHaveBeenCalledTimes(1);
54+
await userEvent.click(settingsLink);
55+
56+
expect(roomProps.notificationVolume).not.toBe("mentions_only");
5157
});
5258
});

0 commit comments

Comments
 (0)