Files
ThreadNet-Web/apps/web/src/autocomplete/UserProvider.test.tsx
T
David BakerandGitHub c09f572fa7 Add user status to autocomplete suggestion (#34241)
* Add user status to autocomplete suggestion

* Add test for PillCompletion titleIcon

* Convert to vitest

* Add test for UserStatusIcon

* Switch the user status icon view to be a view model based component

* Screenshots

* Add .catch

* Add test for UserProvider
2026-07-14 13:47:24 +00:00

39 lines
1.3 KiB
TypeScript

/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
// @vitest-environment happy-dom
import { describe, it, expect } from "vitest";
import UserProvider from "./UserProvider";
import { makeUserPermalink } from "../utils/permalinks/Permalinks";
import { mkRoom, mkRoomMember, stubClient } from "../../test/test-utils";
describe("UserProvider", () => {
it("suggests a room member whose id matches the query", async () => {
const client = stubClient();
const room = mkRoom(client, "!room:e.com");
const alice = mkRoomMember(room.roomId, "@alice:e.com");
room.getJoinedMembers.mockReturnValue([alice]);
const userProvider = new UserProvider(room);
const completions = await userProvider.getCompletions("@ali", { beginning: true, start: 0, end: 4 });
expect(completions).toStrictEqual([
{
completion: alice.rawDisplayName,
completionId: alice.userId,
type: "user",
suffix: ": ",
href: makeUserPermalink(alice.userId),
component: expect.anything(),
range: { start: 0, end: 4 },
},
]);
});
});