mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-10-22 21:11:23 +00:00
feat(stats): add Paths and Hashes analytics (#57)
This commit is contained in:
1 parent
2405e1ac96
commit
929ba83cf1
12 files changed
+303
-3
No files matched your search
@@ -1,8 +1,19 @@
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import { getStatsObservations, getStatsScopes, getSignalStats } from "../../src/api/client";
|
||||
import { getStatsObservations, getStatsScopes, getSignalStats, getPathStats } from "../../src/api/client";
|
||||
|
||||
afterEach(() => vi.unstubAllGlobals());
|
||||
|
||||
it("sends path window bounds, regional filters and cancellation", async () => {
|
||||
const fetcher = vi.fn<typeof fetch>(async () => ({ ok: true, json: async () => ({}) }) as Response);
|
||||
vi.stubGlobal("fetch", fetcher);
|
||||
const controller = new AbortController();
|
||||
await getPathStats(0, 1000, ["YVR", "YYJ"], controller.signal);
|
||||
const url = new URL(fetcher.mock.calls[0]![0] as string);
|
||||
expect(url.pathname).toContain("/stats/paths");
|
||||
expect(Object.fromEntries(url.searchParams)).toEqual({ since: "0", until: "1000", iatas: "YVR,YYJ" });
|
||||
expect(fetcher.mock.calls[0]![1]).toEqual({ signal: controller.signal });
|
||||
});
|
||||
|
||||
it("forwards region and cancellation to both aggregate endpoints, omitting an empty global filter", async () => {
|
||||
const fetcher = vi.fn<typeof fetch>(async () => ({ ok: true, json: async () => [] }) as Response);
|
||||
vi.stubGlobal("fetch", fetcher);
|
||||
|
||||
Reference in new issue
Block a user