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

Quelle  node-resolve.test.ts

  Sprache: JAVA
 

import { describe, expect, it } from "vitest";
import { resolveNodeFromNodeList, resolveNodeIdFromNodeList } from "./node-resolve.js";

describe("shared/node-resolve", () => {
  const nodes = [
    { nodeId: "mac-123", displayName: "Mac Studio", connected: true },
    { nodeId: "pi-456", displayName: "Raspberry Pi", connected: false },
  ];

  it("resolves node ids through candidate matching", () => {
    expect(resolveNodeIdFromNodeList(nodes, "Mac Studio")).toBe("mac-123");
  });

  it("supports optional default-node selection when query is blank", () => {
    expect(
      resolveNodeIdFromNodeList(nodes, "   ", {
        allowDefault: true,
        pickDefaultNode: (entries) => entries.find((entry) => entry.connected) ?? null,
      }),
    ).toBe("mac-123");
  });

  it("passes the original node list to the default picker", () => {
    expect(
      resolveNodeIdFromNodeList(nodes, "", {
        allowDefault: true,
        pickDefaultNode: (entries) => {
          expect(entries).toBe(nodes);
          return entries[1] ?? null;
        },
      }),
    ).toBe("pi-456");
  });

  it("still throws when default selection is disabled or returns null", () => {
    expect(() => resolveNodeIdFromNodeList(nodes, "   ")).toThrow(/node required/);
    expect(() =>
      resolveNodeIdFromNodeList(nodes, "", {
        allowDefault: true,
        pickDefaultNode: () => null,
      }),
    ).toThrow(/node required/);
  });

  it("returns the full node object and falls back to a synthetic entry when needed", () => {
    expect(resolveNodeFromNodeList(nodes, "pi-456")).toEqual(nodes[1]);
    expect(
      resolveNodeFromNodeList([], "", {
        allowDefault: true,
        pickDefaultNode: () => ({ nodeId: "synthetic-1" }),
      }),
    ).toEqual({ nodeId: "synthetic-1" });
  });
});

Messung V0.5 in Prozent
C=100 H=100 G=100

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

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