Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openclaw/src/infra/outbound/   (Openclaw AI Version 22©)  Datei vom 26.3.2026 mit Größe 1 kB image not shown  

Quelle  channel-target.test.ts

  Sprache: JAVA
 

import { describe, expect, it } from "vitest";
import { applyTargetToParams } from "./channel-target.js";

describe("applyTargetToParams", () => {
  it.each([
    {
      params: {
        action: "send",
        args: { target: "  channel:C1  " } as Record<string, unknown>,
      },
      field: "to",
      expected: "channel:C1",
    },
    {
      params: {
        action: "channel-info",
        args: { target: "  C123  " } as Record<string, unknown>,
      },
      field: "channelId",
      expected: "C123",
    },
  ])("maps trimmed target into configured field for %j", ({ params, field, expected }) => {
    applyTargetToParams(params);
    expect(params.args[field]).toBe(expected);
  });

  it("throws on legacy destination fields when the action has canonical target support", () => {
    expect(() =>
      applyTargetToParams({
        action: "send",
        args: {
          target: "channel:C1",
          to: "legacy",
        },
      }),
    ).toThrow("Use `target` instead of `to`/`channelId`.");
  });

  it.each([
    {
      params: {
        action: "broadcast",
        args: {
          to: "legacy",
        },
      },
      expectedMessage: "Use `target` for actions that accept a destination.",
    },
    {
      params: {
        action: "broadcast",
        args: {
          target: "channel:C1",
        },
      },
      expectedMessage: "Action broadcast does not accept a target.",
    },
  ])("throws on invalid no-target action destination for %j", ({ params, expectedMessage }) => {
    expect(() => applyTargetToParams(params)).toThrow(expectedMessage);
  });

  it("does nothing when target is blank", () => {
    const params = {
      action: "send",
      args: { target: "   " } as Record<string, unknown>,
    };

    applyTargetToParams(params);

    expect(params.args).toEqual({ target: "   " });
  });
});

Messung V0.5 in Prozent
C=98 H=96 G=96

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

*© 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.