Eine aufbereitete Darstellung der Quelle

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

Benutzer

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.19 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


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