mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
test(withings): teach the fallback mock the shape its function now returns
The sync function was widened to answer with what it wrote rather than a bare count. This mock still resolved to a number, so the handler destructured `imported` off it, got undefined, and reported `measurements_imported: NaN`. Nothing in the type system could see it: `vi.fn().mockResolvedValue(0)` carries no relation to the real signature, so a widened contract drifts past every mock in the tree unnoticed. This was the only sibling; the class is worth a sweep of its own.
This commit is contained in:
1 parent
51dbfefbcb
commit
dddd2164b1
1 file changed
+4
-2
@@ -4,7 +4,9 @@ import type { Job } from "pg-boss";
|
||||
const retryDueWithingsWebhookSubscriptions = vi.hoisted(() =>
|
||||
vi.fn().mockResolvedValue(0),
|
||||
);
|
||||
const syncUserMeasurements = vi.hoisted(() => vi.fn().mockResolvedValue(0));
|
||||
const syncUserMeasurements = vi.hoisted(() =>
|
||||
vi.fn().mockResolvedValue({ imported: 0, failed: false }),
|
||||
);
|
||||
const findMany = vi.hoisted(() => vi.fn().mockResolvedValue([]));
|
||||
const addWarning = vi.hoisted(() => vi.fn());
|
||||
|
||||
@@ -63,7 +65,7 @@ beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
findMany.mockResolvedValue([]);
|
||||
retryDueWithingsWebhookSubscriptions.mockResolvedValue(0);
|
||||
syncUserMeasurements.mockResolvedValue(0);
|
||||
syncUserMeasurements.mockResolvedValue({ imported: 0, failed: false });
|
||||
});
|
||||
|
||||
describe("handleWithingsFallbackSync subscription repair", () => {
|
||||
|
||||
Reference in new issue
Block a user