* Remove stale max-len disablements * Remove stale camelCase & naming-convention disablements * Remove stale ban-ts-comment disablements * Remove stale no-var disablements * Remove stale no-empty-property disablements * Remove stale react rule disablements * Remove stale no-constant-condition disablements * Remove stale no-unused-vars disablements * Remove stale disablements for disabled rules * fixup camelcase * Remove dead code * Tidy code * Tweak oxlint config * Use oxlint to apply jsx/tsx extension consistently * Fix import * Fix imports * Rename affected snapshots * Update more imports
39 lines
1.3 KiB
TypeScript
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 },
|
|
},
|
|
]);
|
|
});
|
|
});
|