mirror of
https://github.com/vector-im/element-web.git
synced 2026-07-08 16:30:07 +00:00
3ab233940c
* Add user status on user profile icon Currently unstyled & no tests * Style the user status icon * Update snapshot for avatar wrapper * More snapshot updates * add if braces * Split out user status functions to avoid circular dep which has the weird effect of just breaking jest's mocking. * type imports * Update imports * Update snapshot * Tests * baseline image * Just snapshot the component itself * User status in user menu first pass, unstyled * fix export * superstylin' * snapshots * Add story & test * Snapshots and re-use the repeated rules * Tests * Fix jest lcov projectRoot config * Change tooltip text to just 'clear' * Add comment & fix console warn * Remove all options screenshot as it's not really particularly useful as a preset story * remove stale screenshot * fix imports --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
56 lines
1.8 KiB
TypeScript
56 lines
1.8 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.
|
|
*/
|
|
|
|
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
|
|
|
|
import { clearUserStatus, setUserStatus, userStatusTextWithinMaxLength } from "../../../src/utils/userStatus";
|
|
import { stubClient } from "../../test-utils";
|
|
|
|
describe("userStatus utils", () => {
|
|
describe("userStatusTextWithinMaxLength", () => {
|
|
it("returns true for text within the max length", () => {
|
|
const text = "a".repeat(256);
|
|
expect(userStatusTextWithinMaxLength(text)).toBe(true);
|
|
});
|
|
it("returns false for text exceeding the max length", () => {
|
|
const text = "a".repeat(257);
|
|
expect(userStatusTextWithinMaxLength(text)).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("setUserStatus", () => {
|
|
let client: MatrixClient;
|
|
|
|
beforeEach(() => {
|
|
client = stubClient();
|
|
});
|
|
|
|
it("sets the user status with valid input", async () => {
|
|
setUserStatus(client, { emoji: "🐳", text: "Feeling a little blue" });
|
|
|
|
expect(client.setExtendedProfileProperty).toHaveBeenCalledWith("org.matrix.msc4426.status", {
|
|
emoji: "🐳",
|
|
text: "Feeling a little blue",
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("clearUserStatus", () => {
|
|
let client: MatrixClient;
|
|
|
|
beforeEach(() => {
|
|
client = stubClient();
|
|
});
|
|
|
|
it("clears the user status", async () => {
|
|
clearUserStatus(client);
|
|
|
|
expect(client.setExtendedProfileProperty).toHaveBeenCalledWith("org.matrix.msc4426.status", null);
|
|
});
|
|
});
|
|
});
|