Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  room.test.ts

  Sprache: JAVA
 

import { describe, expect, it, vi } from "vitest";
import type { MatrixClient } from "../sdk.js";
import { getMatrixMemberInfo, getMatrixRoomInfo } from "./room.js";

function createRoomClient() {
  const getRoomStateEvent = vi.fn(async (_roomId: string, eventType: string) => {
    switch (eventType) {
      case "m.room.name":
        return { name: "Ops Room" };
      case "m.room.topic":
        return { topic: "Incidents" };
      case "m.room.canonical_alias":
        return { alias: "#ops:example.org" };
      default:
        throw new Error(`unexpected state event ${eventType}`);
    }
  });
  const getJoinedRoomMembers = vi.fn(async () => [
    { user_id: "@alice:example.org" },
    { user_id: "@bot:example.org" },
  ]);
  const getUserProfile = vi.fn(async () => ({
    displayname: "Alice",
    avatar_url: "mxc://example.org/alice",
  }));

  return {
    client: {
      getRoomStateEvent,
      getJoinedRoomMembers,
      getUserProfile,
      stop: vi.fn(),
    } as unknown as MatrixClient,
    getRoomStateEvent,
    getJoinedRoomMembers,
    getUserProfile,
  };
}

describe("matrix room actions", () => {
  it("returns room details from the resolved Matrix room id", async () => {
    const { client, getJoinedRoomMembers, getRoomStateEvent } = createRoomClient();

    const result = await getMatrixRoomInfo("room:!ops:example.org", { client });

    expect(getRoomStateEvent).toHaveBeenCalledWith("!ops:example.org""m.room.name""");
    expect(getJoinedRoomMembers).toHaveBeenCalledWith("!ops:example.org");
    expect(result).toEqual({
      roomId: "!ops:example.org",
      name: "Ops Room",
      topic: "Incidents",
      canonicalAlias: "#ops:example.org",
      altAliases: [],
      memberCount: 2,
    });
  });

  it("resolves optional room ids when looking up member info", async () => {
    const { client, getUserProfile } = createRoomClient();

    const result = await getMatrixMemberInfo("@alice:example.org", {
      client,
      roomId: "room:!ops:example.org",
    });

    expect(getUserProfile).toHaveBeenCalledWith("@alice:example.org");
    expect(result).toEqual({
      userId: "@alice:example.org",
      profile: {
        displayName: "Alice",
        avatarUrl: "mxc://example.org/alice",
      },
      membership: null,
      powerLevel: null,
      displayName: "Alice",
      roomId: "!ops:example.org",
    });
  });
});

Messung V0.5 in Prozent
C=96 H=92 G=93

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-06) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik