Files
planet/frontend/public/earth/js/interactive-picking.test.js
rayd1o dd41588527
ci / backend (push) Has been cancelled
ci / frontend (push) Has been cancelled
ci / delivery (push) Has been cancelled
release / images (push) Has been cancelled
release: bump version to 0.76.2
2026-10-01 02:29:49 +08:00

33 lines
1.3 KiB
JavaScript

import { expect, test } from "bun:test";
import { pickNearestInteractiveHit, pickNearestPointCandidate } from "./interactive-picking.js";
const hit = (object, distancePxSq, cluster = false) => ({ object, distancePxSq, cluster });
test("screen distance wins across icon layers", () => {
expect(pickNearestInteractiveHit([
{ type: "bgp_collector", hits: [hit("rrc26", 64)] },
{ type: "compute_center", hits: [hit("gpu", 9)] },
]).object).toBe("gpu");
});
test("render priority resolves an exact overlap without letting the lower collector steal it", () => {
expect(pickNearestInteractiveHit([
{ type: "bgp_collector", hits: [hit("rrc22", 16)] },
{ type: "compute_center", hits: [hit("gpu", 16)] },
]).object).toBe("gpu");
});
test("cluster hits are ignored while pointer eligibility remains true for real markers", () => {
expect(pickNearestInteractiveHit([
{ type: "compute_center", hits: [hit("cluster", 1, true)] },
{ type: "bgp_collector", hits: [hit("rrc22", 9)] },
]).object).toBe("rrc22");
});
test("nearest point candidate is resolved before the line fallback", () => {
expect(pickNearestPointCandidate([
{ type: "compute_center", object: "compute", distancePxSq: 16 },
{ type: "satellite", object: "satellite", distancePxSq: 0 },
]).type).toBe("satellite");
});