|
| 1 | +/* |
| 2 | +Copyright 2025 Element Creations Ltd. |
| 3 | +
|
| 4 | +SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial |
| 5 | +Please see LICENSE files in the repository root for full details. |
| 6 | +*/ |
| 7 | +import React from "react"; |
| 8 | +import { render, screen } from "jest-matrix-react"; |
| 9 | + |
| 10 | +import type { Room } from "matrix-js-sdk/src/matrix"; |
| 11 | +import { ModuleNotificationDecoration } from "../../../../src/modules/components/ModuleNotificationDecoration"; |
| 12 | +import { mkStubRoom, stubClient } from "../../../test-utils"; |
| 13 | +import { NotificationLevel } from "../../../../src/stores/notifications/NotificationLevel"; |
| 14 | +import { RoomNotificationStateStore } from "../../../../src/stores/notifications/RoomNotificationStateStore"; |
| 15 | +import { RoomNotificationState } from "../../../../src/stores/notifications/RoomNotificationState"; |
| 16 | + |
| 17 | +class MockedNotificationState extends RoomNotificationState { |
| 18 | + public constructor(room: Room, level: NotificationLevel, count: number) { |
| 19 | + super(room, false); |
| 20 | + this._level = level; |
| 21 | + this._count = count; |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +it("Should be able to render component just with room as prop", () => { |
| 26 | + const cli = stubClient(); |
| 27 | + const room = mkStubRoom("!foo:matrix.org", "Foo Room", cli); |
| 28 | + jest.spyOn(RoomNotificationStateStore.instance, "getRoomState").mockReturnValue( |
| 29 | + new MockedNotificationState(room, NotificationLevel.Notification, 5), |
| 30 | + ); |
| 31 | + render(<ModuleNotificationDecoration room={room} />); |
| 32 | + expect(screen.getByTestId("notification-decoration")).toBeInTheDocument(); |
| 33 | +}); |
0 commit comments