mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
refactor(normalization): reuse trimmed list helpers (#113295)
This commit is contained in:
@@ -3,10 +3,12 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
normalizeAtHashSlug,
|
||||
normalizeHyphenSlug,
|
||||
normalizeOptionalTrimmedStringList,
|
||||
normalizeSortedUniqueStringEntries,
|
||||
normalizeSortedUniqueTrimmedStringList,
|
||||
normalizeStringEntries,
|
||||
normalizeStringEntriesLower,
|
||||
normalizeTrimmedStringList,
|
||||
normalizeUniqueSingleOrTrimmedStringList,
|
||||
normalizeUniqueStringEntries,
|
||||
normalizeUniqueStringEntriesLower,
|
||||
@@ -59,6 +61,14 @@ describe("normalization-core/string-normalization", () => {
|
||||
expect(normalizeUniqueTrimmedStringList("b")).toEqual([]);
|
||||
});
|
||||
|
||||
it("normalizes array-backed trimmed string lists", () => {
|
||||
const values = [" first ", "", 42, " second ", null];
|
||||
expect(normalizeTrimmedStringList(values)).toEqual(["first", "second"]);
|
||||
expect(normalizeTrimmedStringList("first")).toEqual([]);
|
||||
expect(normalizeOptionalTrimmedStringList(values)).toEqual(["first", "second"]);
|
||||
expect(normalizeOptionalTrimmedStringList(["", 42])).toBeUndefined();
|
||||
});
|
||||
|
||||
it("normalizes sorted unique trimmed string lists", () => {
|
||||
expect(normalizeSortedUniqueTrimmedStringList([" b ", "a", "b", "", "a"])).toEqual(["a", "b"]);
|
||||
expect(normalizeSortedUniqueTrimmedStringList(["z", 1, " a "] as unknown[])).toEqual([
|
||||
|
||||
Reference in New Issue
Block a user