mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-09-05 05:03:45 +00:00
24 lines
1.0 KiB
TypeScript
24 lines
1.0 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { nodeSearchParams } from "../../../src/features/nodes/node-search";
|
|
|
|
describe("nodeSearchParams", () => {
|
|
it("maps the name field to the name param", () => {
|
|
expect(nodeSearchParams("name", "alpha")).toEqual({ name: "alpha" });
|
|
});
|
|
|
|
it("maps the pubkey field to a lowercased hex prefix", () => {
|
|
expect(nodeSearchParams("pubkey", "AB12")).toEqual({ pubkeyPrefix: "ab12" });
|
|
});
|
|
|
|
it("drops a non-hex pubkey prefix instead of firing a request the server 400s", () => {
|
|
// names/spaces are non-hex; sending them as pubkeyPrefix would 400 the whole table
|
|
expect(nodeSearchParams("pubkey", "alice")).toEqual({ pubkeyPrefix: undefined });
|
|
expect(nodeSearchParams("pubkey", "de ad")).toEqual({ pubkeyPrefix: undefined });
|
|
});
|
|
|
|
it("treats blank input as no filter on either field", () => {
|
|
expect(nodeSearchParams("name", " ")).toEqual({ name: undefined });
|
|
expect(nodeSearchParams("pubkey", "")).toEqual({ pubkeyPrefix: undefined });
|
|
});
|
|
});
|