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

Quelle  account-id.test.ts

  Sprache: JAVA
 

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

import { describe, expect, it } from "vitest";
import {
  DEFAULT_ACCOUNT_ID,
  normalizeAccountId,
  normalizeOptionalAccountId,
} from "./account-id.js";

describe("account id normalization", () => {
  const reservedAccountIdCases = [
    { name: "rejects __proto__ pollution keys", input: "__proto__" },
    { name: "rejects constructor pollution keys", input: "constructor" },
    { name: "rejects prototype pollution keys", input: "prototype" },
  ] as const;

  function expectNormalizedAccountIdCase(params: {
    input: string | null | undefined;
    expected: string | undefined;
    optional?: boolean;
  }) {
    const normalize = params.optional ? normalizeOptionalAccountId : normalizeAccountId;
    expect(normalize(params.input)).toBe(params.expected);
  }

  it.each([
    {
      name: "defaults undefined to default account",
      input: undefined,
      expected: DEFAULT_ACCOUNT_ID,
    },
    { name: "defaults null to default account", input: null, expected: DEFAULT_ACCOUNT_ID },
    {
      name: "defaults blank strings to default account",
      input: "   ",
      expected: DEFAULT_ACCOUNT_ID,
    },
    { name: "normalizes valid ids to lowercase", input: "  Business_1  ", expected: "business_1" },
    {
      name: "sanitizes invalid characters into canonical ids",
      input: " Prod/US East ",
      expected: "prod-us-east",
    },
    ...reservedAccountIdCases.map(({ name, input }) => ({
      name,
      input,
      expected: DEFAULT_ACCOUNT_ID,
    })),
  ] as const)("$name", ({ input, expected }) => {
    expectNormalizedAccountIdCase({ input, expected });
  });

  it.each([
    { name: "keeps undefined optional values unset", input: undefined, expected: undefined },
    { name: "keeps blank optional values unset", input: "   ", expected: undefined },
    { name: "keeps invalid optional values unset", input: " !!! ", expected: undefined },
    ...reservedAccountIdCases.map(({ name, input }) => ({
      name: name.replace(" pollution keys", " optional values"),
      input,
      expected: undefined,
    })),
    { name: "normalizes valid optional values", input: "  Business  ", expected: "business" },
  ] as const)("$name", ({ input, expected }) => {
    expectNormalizedAccountIdCase({ input, expected, optional: true });
  });
});

¤ Dauer der Verarbeitung: 0.15 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.