Spaces:
Running
Running
Download server/parseCommaSeparatedList.test.ts from Felladrin/MiniSearch: direct link, hf CLI and curl.
- Browser
- Download file 872 Bytes
-
https://huggingface.co/spaces/Felladrin/MiniSearch/resolve/main/server/parseCommaSeparatedList.test.ts
- Command line
-
hf download hf://spaces/Felladrin/MiniSearch/server/parseCommaSeparatedList.test.ts
-
curl -L -o parseCommaSeparatedList.test.ts https://huggingface.co/spaces/Felladrin/MiniSearch/resolve/main/server/parseCommaSeparatedList.test.ts
872 Bytes
| import { describe, expect, it } from "vitest"; | |
| import { parseCommaSeparatedList } from "./parseCommaSeparatedList"; | |
| describe("parseCommaSeparatedList", () => { | |
| it("splits on commas", () => { | |
| expect(parseCommaSeparatedList("a,b,c")).toEqual(["a", "b", "c"]); | |
| }); | |
| it("trims whitespace around each entry", () => { | |
| expect(parseCommaSeparatedList("localhost, example.com ")).toEqual([ | |
| "localhost", | |
| "example.com", | |
| ]); | |
| }); | |
| it("drops empty entries", () => { | |
| expect(parseCommaSeparatedList("key1, key2,")).toEqual(["key1", "key2"]); | |
| expect(parseCommaSeparatedList(",")).toEqual([]); | |
| expect(parseCommaSeparatedList(" , ,")).toEqual([]); | |
| }); | |
| it("returns an empty list for an unset or empty value", () => { | |
| expect(parseCommaSeparatedList(undefined)).toEqual([]); | |
| expect(parseCommaSeparatedList("")).toEqual([]); | |
| }); | |
| }); | |