You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-30 02:21:17 +03:00
Merge branch 'develop' into andybalaam/stas-demydiuk-membership-type3
This commit is contained in:
@ -22,6 +22,7 @@ import {
|
||||
NotificationCountType,
|
||||
EventType,
|
||||
MatrixEvent,
|
||||
RoomEvent,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { KnownMembership } from "matrix-js-sdk/src/types";
|
||||
|
||||
@ -81,7 +82,7 @@ describe("RoomNotificationState", () => {
|
||||
room.setUnreadNotificationCount(NotificationCountType.Total, greys);
|
||||
}
|
||||
|
||||
it("Updates on event decryption", () => {
|
||||
it("updates on event decryption", () => {
|
||||
const roomNotifState = new RoomNotificationState(room, true);
|
||||
const listener = jest.fn();
|
||||
roomNotifState.addListener(NotificationStateEvents.Update, listener);
|
||||
@ -93,6 +94,36 @@ describe("RoomNotificationState", () => {
|
||||
expect(listener).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("emits an Update event on marked unread room account data", () => {
|
||||
const roomNotifState = new RoomNotificationState(room, true);
|
||||
const listener = jest.fn();
|
||||
roomNotifState.addListener(NotificationStateEvents.Update, listener);
|
||||
const accountDataEvent = {
|
||||
getType: () => "com.famedly.marked_unread",
|
||||
getContent: () => {
|
||||
return { unread: true };
|
||||
},
|
||||
} as unknown as MatrixEvent;
|
||||
room.getAccountData = jest.fn().mockReturnValue(accountDataEvent);
|
||||
room.emit(RoomEvent.AccountData, accountDataEvent, room);
|
||||
expect(listener).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not update on other account data", () => {
|
||||
const roomNotifState = new RoomNotificationState(room, true);
|
||||
const listener = jest.fn();
|
||||
roomNotifState.addListener(NotificationStateEvents.Update, listener);
|
||||
const accountDataEvent = {
|
||||
getType: () => "else.something",
|
||||
getContent: () => {
|
||||
return {};
|
||||
},
|
||||
} as unknown as MatrixEvent;
|
||||
room.getAccountData = jest.fn().mockReturnValue(accountDataEvent);
|
||||
room.emit(RoomEvent.AccountData, accountDataEvent, room);
|
||||
expect(listener).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("removes listeners", () => {
|
||||
const roomNotifState = new RoomNotificationState(room, false);
|
||||
expect(() => roomNotifState.destroy()).not.toThrow();
|
||||
|
Reference in New Issue
Block a user