test: add widget config tests (batch 7)

This commit is contained in:
shamoon
2026-02-04 10:10:38 -08:00
parent ed54a22841
commit 254b2cb2e4
21 changed files with 234 additions and 1 deletions

View File

@@ -32,7 +32,20 @@ export function expectWidgetConfigShape(widget) {
expect(mapping.endpoint.length).toBeGreaterThan(0);
}
if ("map" in mapping) {
expect(mapping.map).toBeTypeOf("function");
const map = mapping.map;
const proxyName = widget.proxyHandler?.name ?? "genericProxyHandler";
// Most handlers treat `map` as a transform function. A small number of custom
// proxies treat it as an options object.
expect(["function", "object"].includes(typeof map)).toBe(true);
if (typeof map === "object") {
expect(map).not.toBeNull();
expect(Array.isArray(map)).toBe(false);
// Generic handlers will call `map(resultData)`, so they must never receive an object.
expect(proxyName).not.toBe("genericProxyHandler");
expect(proxyName).not.toBe("credentialedProxyHandler");
}
}
}
}