mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 06:52:04 +00:00
style: apply prettier across the tree
One-shot prettier pass so the new format:check gate starts from a clean baseline. Formatting only — no behaviour change. Generator-owned and vendored artifacts stay untouched via .prettierignore.
This commit is contained in:
1 parent
b3fea2ef59
commit
1f4ba5939d
1000 files changed
+12130
-8385
No files matched your search
@@ -1,9 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
createBiomarkerSchema,
|
||||
updateBiomarkerSchema,
|
||||
} from "../biomarkers";
|
||||
import { createBiomarkerSchema, updateBiomarkerSchema } from "../biomarkers";
|
||||
|
||||
describe("createBiomarkerSchema", () => {
|
||||
it("accepts a minimal marker (name + unit only)", () => {
|
||||
|
||||
@@ -12,17 +12,16 @@ const NOW = Date.parse("2026-06-14T12:00:00.000Z");
|
||||
|
||||
describe("isPlausibleEntryInstant", () => {
|
||||
it("accepts a recent past instant", () => {
|
||||
expect(
|
||||
isPlausibleEntryInstant(new Date(NOW - 60_000), { now: NOW }),
|
||||
).toBe(true);
|
||||
expect(isPlausibleEntryInstant(new Date(NOW - 60_000), { now: NOW })).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("accepts an instant inside the clock-skew tolerance", () => {
|
||||
expect(
|
||||
isPlausibleEntryInstant(
|
||||
new Date(NOW + ENTRY_INSTANT_CLOCK_SKEW_MS - 1),
|
||||
{ now: NOW },
|
||||
),
|
||||
isPlausibleEntryInstant(new Date(NOW + ENTRY_INSTANT_CLOCK_SKEW_MS - 1), {
|
||||
now: NOW,
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
@@ -37,10 +36,9 @@ describe("isPlausibleEntryInstant", () => {
|
||||
|
||||
it("rejects an instant before the 1900 far-past floor", () => {
|
||||
expect(
|
||||
isPlausibleEntryInstant(
|
||||
new Date(ENTRY_INSTANT_FAR_PAST.getTime() - 1),
|
||||
{ now: NOW },
|
||||
),
|
||||
isPlausibleEntryInstant(new Date(ENTRY_INSTANT_FAR_PAST.getTime() - 1), {
|
||||
now: NOW,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -462,7 +462,10 @@ describe("measurement validation", () => {
|
||||
const issue = parsed.error.issues.find((i) =>
|
||||
i.path.includes("source"),
|
||||
);
|
||||
expect(issue, `expected a source-path rejection for ${source}`).toBeDefined();
|
||||
expect(
|
||||
issue,
|
||||
`expected a source-path rejection for ${source}`,
|
||||
).toBeDefined();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -103,12 +103,12 @@ describe("medication schemas — dosesPerUnit cap 1000 + unitsPerDose 1–100",
|
||||
});
|
||||
|
||||
it("update accepts dosesPerUnit 1000 and rejects 1001", () => {
|
||||
expect(updateMedicationSchema.safeParse({ dosesPerUnit: 1000 }).success).toBe(
|
||||
true,
|
||||
);
|
||||
expect(updateMedicationSchema.safeParse({ dosesPerUnit: 1001 }).success).toBe(
|
||||
false,
|
||||
);
|
||||
expect(
|
||||
updateMedicationSchema.safeParse({ dosesPerUnit: 1000 }).success,
|
||||
).toBe(true);
|
||||
expect(
|
||||
updateMedicationSchema.safeParse({ dosesPerUnit: 1001 }).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("create bounds unitsPerDose to 1–100", () => {
|
||||
@@ -167,9 +167,9 @@ describe("medication schemas — dosesPerUnit cap 1000 + unitsPerDose 1–100",
|
||||
unitsPerDose: v,
|
||||
}).success,
|
||||
).toBe(true);
|
||||
expect(updateMedicationSchema.safeParse({ unitsPerDose: v }).success).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
updateMedicationSchema.safeParse({ unitsPerDose: v }).success,
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -196,9 +196,21 @@ describe("medication schemas — dosesPerUnit cap 1000 + unitsPerDose 1–100",
|
||||
|
||||
describe("glp1InventoryPostSchema — the legacy pen-ledger delta keeps ±100", () => {
|
||||
it("accepts ±100 and rejects ±101", () => {
|
||||
expect(glp1InventoryPostSchema.safeParse({ delta: 100, reason: "purchased" }).success).toBe(true);
|
||||
expect(glp1InventoryPostSchema.safeParse({ delta: -100, reason: "damaged" }).success).toBe(true);
|
||||
expect(glp1InventoryPostSchema.safeParse({ delta: 101, reason: "purchased" }).success).toBe(false);
|
||||
expect(glp1InventoryPostSchema.safeParse({ delta: -101, reason: "damaged" }).success).toBe(false);
|
||||
expect(
|
||||
glp1InventoryPostSchema.safeParse({ delta: 100, reason: "purchased" })
|
||||
.success,
|
||||
).toBe(true);
|
||||
expect(
|
||||
glp1InventoryPostSchema.safeParse({ delta: -100, reason: "damaged" })
|
||||
.success,
|
||||
).toBe(true);
|
||||
expect(
|
||||
glp1InventoryPostSchema.safeParse({ delta: 101, reason: "purchased" })
|
||||
.success,
|
||||
).toBe(false);
|
||||
expect(
|
||||
glp1InventoryPostSchema.safeParse({ delta: -101, reason: "damaged" })
|
||||
.success,
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -29,7 +29,8 @@ describe("createMoodEntrySchema — note + structured tagKeys (v1.8.5)", () => {
|
||||
|
||||
it("rejects an over-long note and an over-large tagKeys set", () => {
|
||||
expect(
|
||||
createMoodEntrySchema.safeParse({ ...base, note: "x".repeat(501) }).success,
|
||||
createMoodEntrySchema.safeParse({ ...base, note: "x".repeat(501) })
|
||||
.success,
|
||||
).toBe(false);
|
||||
expect(
|
||||
createMoodEntrySchema.safeParse({
|
||||
|
||||
@@ -242,8 +242,12 @@ describe("DEFAULT_SOURCE_PRIORITY", () => {
|
||||
const ladder = DEFAULT_SOURCE_PRIORITY[key];
|
||||
expect(ladder).toContain("OURA");
|
||||
expect(ladder).toContain("POLAR");
|
||||
expect(ladder.indexOf("OURA")).toBeLessThan(ladder.indexOf("APPLE_HEALTH"));
|
||||
expect(ladder.indexOf("POLAR")).toBeLessThan(ladder.indexOf("APPLE_HEALTH"));
|
||||
expect(ladder.indexOf("OURA")).toBeLessThan(
|
||||
ladder.indexOf("APPLE_HEALTH"),
|
||||
);
|
||||
expect(ladder.indexOf("POLAR")).toBeLessThan(
|
||||
ladder.indexOf("APPLE_HEALTH"),
|
||||
);
|
||||
expect(ladder.indexOf("WHOOP")).toBeLessThan(ladder.indexOf("OURA"));
|
||||
}
|
||||
});
|
||||
@@ -451,10 +455,7 @@ describe("getSourceLadder + getDeviceTypeLadder helpers", () => {
|
||||
WEIGHT: ["scale", "watch"],
|
||||
},
|
||||
});
|
||||
expect(getDeviceTypeLadder(resolved, "WEIGHT")).toEqual([
|
||||
"scale",
|
||||
"watch",
|
||||
]);
|
||||
expect(getDeviceTypeLadder(resolved, "WEIGHT")).toEqual(["scale", "watch"]);
|
||||
});
|
||||
|
||||
it("getDeviceTypeLadder falls back to the user default ladder", () => {
|
||||
@@ -501,9 +502,9 @@ describe("parseSourcePriority — stored-ladder reconciliation (v1.16.11)", () =
|
||||
expect(resolved.metricPriority.sleep).toContain("WHOOP");
|
||||
expect(resolved.metricPriority.sleep).toContain("FITBIT");
|
||||
expect(resolved.metricPriority.sleep.indexOf("WHOOP")).toBeGreaterThan(3);
|
||||
expect(
|
||||
resolved.metricPriority.sleep.indexOf("WHOOP"),
|
||||
).toBeLessThan(resolved.metricPriority.sleep.indexOf("FITBIT"));
|
||||
expect(resolved.metricPriority.sleep.indexOf("WHOOP")).toBeLessThan(
|
||||
resolved.metricPriority.sleep.indexOf("FITBIT"),
|
||||
);
|
||||
});
|
||||
|
||||
it("leaves a complete stored ladder byte-identical", () => {
|
||||
@@ -529,13 +530,7 @@ describe("parseSourcePriority — duplicate tolerance (v1.16.11)", () => {
|
||||
it("collapses duplicates so a resolved ladder can never overflow the schema cap", () => {
|
||||
const resolved = parseSourcePriority({
|
||||
metricPriority: {
|
||||
weight: [
|
||||
"MANUAL",
|
||||
"MANUAL",
|
||||
"WITHINGS",
|
||||
"MANUAL",
|
||||
"WITHINGS",
|
||||
],
|
||||
weight: ["MANUAL", "MANUAL", "WITHINGS", "MANUAL", "WITHINGS"],
|
||||
},
|
||||
});
|
||||
const ladder = resolved.metricPriority.weight;
|
||||
|
||||
@@ -135,9 +135,7 @@ describe("workoutHrSamplesSchema", () => {
|
||||
|
||||
it("rejects an out-of-range heart rate", () => {
|
||||
expect(() =>
|
||||
workoutHrSamplesSchema.parse([
|
||||
{ t: "2026-05-14T07:00:00.000Z", hr: 5 },
|
||||
]),
|
||||
workoutHrSamplesSchema.parse([{ t: "2026-05-14T07:00:00.000Z", hr: 5 }]),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
@@ -155,13 +153,10 @@ describe("workoutHrSamplesSchema", () => {
|
||||
});
|
||||
|
||||
it("accepts a series exactly at the cap", () => {
|
||||
const atCap = Array.from(
|
||||
{ length: MAX_WORKOUT_HR_SAMPLES },
|
||||
(_v, i) => ({
|
||||
t: new Date(Date.UTC(2026, 4, 14, 7, 0, 0) + i * 1000).toISOString(),
|
||||
hr: 140,
|
||||
}),
|
||||
);
|
||||
const atCap = Array.from({ length: MAX_WORKOUT_HR_SAMPLES }, (_v, i) => ({
|
||||
t: new Date(Date.UTC(2026, 4, 14, 7, 0, 0) + i * 1000).toISOString(),
|
||||
hr: 140,
|
||||
}));
|
||||
expect(workoutHrSamplesSchema.parse(atCap)).toHaveLength(
|
||||
MAX_WORKOUT_HR_SAMPLES,
|
||||
);
|
||||
@@ -370,9 +365,8 @@ describe("createBatchWorkoutSchema", () => {
|
||||
});
|
||||
|
||||
it("accepts a batch at the cap (100 workouts)", () => {
|
||||
const workouts = Array.from(
|
||||
{ length: MAX_WORKOUTS_PER_BATCH },
|
||||
(_, i) => minimalRun(`hk-uuid-${i}`),
|
||||
const workouts = Array.from({ length: MAX_WORKOUTS_PER_BATCH }, (_, i) =>
|
||||
minimalRun(`hk-uuid-${i}`),
|
||||
);
|
||||
const parsed = createBatchWorkoutSchema.parse({ workouts });
|
||||
expect(parsed.workouts).toHaveLength(MAX_WORKOUTS_PER_BATCH);
|
||||
|
||||
Reference in new issue
Block a user