mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-10-18 11:10:15 +00:00
Lands the stacked web PRs #75, #79, #80, #81, #83, #85, #87, #89, #92, #95 and #99 in one squash. Server counterparts #166-#176 are merged. Remaining review items follow in a fix PR.
17 lines
898 B
TypeScript
17 lines
898 B
TypeScript
import { afterEach, expect, it, vi } from "vitest";
|
|
import { getRouteEvidence } from "../../src/api/client";
|
|
|
|
afterEach(() => vi.unstubAllGlobals());
|
|
it("encodes route identity and preserves the opaque cursor without numeric truncation", async () => {
|
|
const fetcher = vi.fn().mockResolvedValue({ ok: true, json: async () => ({ items: [], hasMore: false }) });
|
|
vi.stubGlobal("fetch", fetcher);
|
|
const cursor = "v1:YOW:abcdef:1:2:1234567890000001:9007199254740993";
|
|
const signal = new AbortController().signal;
|
|
await getRouteEvidence("Y/W", "abc/def", { pageCursor: cursor, limit: 50 }, signal);
|
|
const url = new URL(fetcher.mock.calls[0][0]);
|
|
expect(url.pathname).toContain("/routes/Y%2FW/abc%2Fdef/observations");
|
|
expect(url.searchParams.get("pageCursor")).toBe(cursor);
|
|
expect(url.searchParams.has("range")).toBe(false);
|
|
expect(fetcher.mock.calls[0][1].signal).toBe(signal);
|
|
});
|