Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MidhunSureshR committed Mar 2, 2025
1 parent 6b61ba9 commit 2c41ade
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ Please see LICENSE files in the repository root for full details.
*/

import { EventType, KnownMembership, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
import { logger } from "matrix-js-sdk/src/logger";

import { RoomListStoreV3Class } from "../../../../src/stores/room-list-v3/RoomListStoreV3";
import { AsyncStoreWithClient } from "../../../../src/stores/AsyncStoreWithClient";
import { RecencySorter } from "../../../../src/stores/room-list-v3/skip-list/sorters/RecencySorter";
import { mkEvent, mkMessage, stubClient, upsertRoomStateEvents } from "../../../test-utils";
import { getMockedRooms } from "./skip-list/getMockedRooms";
import { AlphabeticSorter } from "../../../../src/stores/room-list-v3/skip-list/sorters/AlphabeticSorter";
import dispatcher from "../../../../src/dispatcher/dispatcher";
import { LISTS_UPDATE_EVENT } from "../../../../src/stores/room-list/RoomListStore";
import dispatcher from "../../../../src/dispatcher/dispatcher";

describe("RoomListStoreV3", () => {
async function getRoomListStore() {
Expand Down Expand Up @@ -185,6 +186,30 @@ describe("RoomListStoreV3", () => {
expect(fn).toHaveBeenCalled();
});

it("Logs a warning if room couldn't be found from room-id on decryption action", async () => {
const { store, client, dispatcher } = await getRoomListStore();
jest.spyOn(client, "getRoom").mockImplementation(() => null);
const warnSpy = jest.spyOn(logger, "warn");

const fn = jest.fn();
store.on(LISTS_UPDATE_EVENT, fn);

// Dispatch a decrypted action but the room does not exist.
dispatcher.dispatch(
{
action: "MatrixActions.Event.decrypted",
event: {
getRoomId: () => "!doesnotexist:matrix.org",
getId: () => "some-id",
},
},
true,
);

expect(warnSpy).toHaveBeenCalled();
expect(fn).not.toHaveBeenCalled();
});

describe("Update from read receipt", () => {
function getReadReceiptEvent(userId: string) {
const content = {
Expand Down

0 comments on commit 2c41ade

Please sign in to comment.