Merge branch 'develop' into andybalaam/stas-demydiuk-membership-type3
This commit is contained in:
commit
d7bdbee8d2
124 changed files with 2399 additions and 1052 deletions
|
@ -108,6 +108,7 @@ describe("RoomViewStore", function () {
|
|||
relations: jest.fn(),
|
||||
knockRoom: jest.fn(),
|
||||
leave: jest.fn(),
|
||||
setRoomAccountData: jest.fn(),
|
||||
});
|
||||
const room = new Room(roomId, mockClient, userId);
|
||||
const room2 = new Room(roomId2, mockClient, userId);
|
||||
|
@ -339,6 +340,17 @@ describe("RoomViewStore", function () {
|
|||
expect(mocked(Modal).createDialog.mock.calls[0][1]).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("clears the unread flag when viewing a room", async () => {
|
||||
room.getAccountData = jest.fn().mockReturnValue({
|
||||
getContent: jest.fn().mockReturnValue({ unread: true }),
|
||||
});
|
||||
dis.dispatch({ action: Action.ViewRoom, room_id: roomId });
|
||||
await untilDispatch(Action.ActiveRoomChanged, dis);
|
||||
expect(mockClient.setRoomAccountData).toHaveBeenCalledWith(roomId, "com.famedly.marked_unread", {
|
||||
unread: false,
|
||||
});
|
||||
});
|
||||
|
||||
describe("when listening to a voice broadcast", () => {
|
||||
let voiceBroadcastPlayback: VoiceBroadcastPlayback;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue