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


Quelle  channel.account-paths.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { beforeEach, describe, expect, it, vi } from "vitest";
import { createMatrixPairingText, createMatrixProbeAccount } from "./channel-account-paths.js";

const sendMessageMatrixMock = vi.hoisted(() => vi.fn());
const probeMatrixMock = vi.hoisted(() => vi.fn());
const resolveMatrixAuthMock = vi.hoisted(() => vi.fn());

vi.mock("./matrix/send.js", async () => {
  const actual = await vi.importActual<typeof import("./matrix/send.js")>("./matrix/send.js");
  return {
    ...actual,
    sendMessageMatrix: (...args: unknown[]) => sendMessageMatrixMock(...args),
  };
});

vi.mock("./matrix/probe.js", async () => {
  const actual = await vi.importActual<typeof import("./matrix/probe.js")>("./matrix/probe.js");
  return {
    ...actual,
    probeMatrix: (...args: unknown[]) => probeMatrixMock(...args),
  };
});

vi.mock("./matrix/client.js", async () => {
  const actual = await vi.importActual<typeof import("./matrix/client.js")>("./matrix/client.js");
  return {
    ...actual,
    resolveMatrixAuth: (...args: unknown[]) => resolveMatrixAuthMock(...args),
  };
});

describe("matrix account path propagation", () => {
  beforeEach(() => {
    vi.clearAllMocks();
    sendMessageMatrixMock.mockResolvedValue({
      messageId: "$sent",
      roomId: "!room:example.org",
    });
    probeMatrixMock.mockResolvedValue({
      ok: true,
      error: null,
      status: null,
      elapsedMs: 5,
      userId: "@poe:example.org",
    });
    resolveMatrixAuthMock.mockResolvedValue({
      accountId: "poe",
      homeserver: "https://matrix.example.org",
      userId: "@poe:example.org",
      accessToken: "poe-token",
      deviceId: "POEDEVICE",
    });
  });

  it("forwards accountId when notifying pairing approval", async () => {
    const pairingText = createMatrixPairingText(sendMessageMatrixMock);

    expect(pairingText.normalizeAllowEntry("  matrix:@user:example.org  ")).toBe(
      "@user:example.org",
    );

    await pairingText.notify({
      cfg: {} as never,
      id: "@user:example.org",
      message: pairingText.message,
      accountId: "poe",
    });

    expect(sendMessageMatrixMock).toHaveBeenCalledWith(
      "user:@user:example.org",
      expect.any(String),
      { cfg: {}, accountId: "poe" },
    );
  });

  it("forwards accountId and deviceId to matrix probes", async () => {
    const probeAccount = createMatrixProbeAccount({
      resolveMatrixAuth: resolveMatrixAuthMock,
      probeMatrix: probeMatrixMock,
    });

    await probeAccount({
      cfg: {} as never,
      timeoutMs: 500,
      account: {
        accountId: "poe",
      } as never,
    });

    expect(resolveMatrixAuthMock).toHaveBeenCalledWith({
      cfg: {},
      accountId: "poe",
    });
    expect(probeMatrixMock).toHaveBeenCalledWith({
      homeserver: "https://matrix.example.org",
      accessToken: "poe-token",
      userId: "@poe:example.org",
      deviceId: "POEDEVICE",
      timeoutMs: 500,
      accountId: "poe",
    });
  });
});

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge