1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

Support dynamic room predecessor in SpaceProvider (#10348)

This commit is contained in:
Andy Balaam
2023-03-10 11:01:45 +00:00
committed by GitHub
parent d244b9065c
commit f8e645396e
3 changed files with 146 additions and 3 deletions

View File

@ -19,7 +19,7 @@ import { MatrixClient, Room } from "matrix-js-sdk/src/matrix";
import RoomProvider from "../../src/autocomplete/RoomProvider";
import SettingsStore from "../../src/settings/SettingsStore";
import { mkRoom, stubClient } from "../test-utils";
import { mkRoom, mkSpace, stubClient } from "../test-utils";
describe("RoomProvider", () => {
it("suggests a room whose alias matches a prefix", async () => {
@ -52,7 +52,8 @@ describe("RoomProvider", () => {
const room1 = makeRoom(client, "room1:e.com");
const room2 = makeRoom(client, "room2:e.com");
const other = makeRoom(client, "other:e.com");
mocked(client.getVisibleRooms).mockReturnValue([room1, room2, other]);
const space = makeSpace(client, "room3:e.com");
mocked(client.getVisibleRooms).mockReturnValue([room1, room2, other, space]);
// When we search for rooms starting with a prefix
const roomProvider = new RoomProvider(room1);
@ -121,6 +122,12 @@ describe("RoomProvider", () => {
});
});
function makeSpace(client: MatrixClient, name: string): Room {
const space = mkSpace(client, `!${name}`);
space.getCanonicalAlias.mockReturnValue(`#${name}`);
return space;
}
function makeRoom(client: MatrixClient, name: string): Room {
const room = mkRoom(client, `!${name}`);
room.getCanonicalAlias.mockReturnValue(`#${name}`);