/* 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); }); }); });