mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
test: pin the km-scale walking distance the export import stores as metres
The Apple export writes DistanceWalkingRunning in the account's own length unit; the record mapping assumes metres and never reads the attribute, so a 2.484 km day lands as 2.484 m. Refs #944
This commit is contained in:
1 parent
1d372df3a0
commit
704ef11eab
1 file changed
+32
@@ -1278,3 +1278,35 @@ describe("streamParseExportXml — the archive's own export stamp", () => {
|
||||
expect(stamps).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("streamParseExportXml — the record's own unit (issue #944)", () => {
|
||||
it("stores a km-scale walking distance in metres", async () => {
|
||||
const { prisma } = await importCumulativeFixture(
|
||||
cumulativeExportXml(
|
||||
"HKQuantityTypeIdentifierDistanceWalkingRunning",
|
||||
"km",
|
||||
[{ value: 2.484, sourceName: "iPhone", hour: 8 }],
|
||||
),
|
||||
);
|
||||
|
||||
expect(prisma._measurements).toHaveLength(1);
|
||||
expect(prisma._measurements[0]).toMatchObject({
|
||||
type: "WALKING_RUNNING_DISTANCE",
|
||||
unit: "m",
|
||||
});
|
||||
expect(prisma._measurements[0].value).toBeCloseTo(2484, 6);
|
||||
});
|
||||
|
||||
it("stores a mile-scale walking distance in metres", async () => {
|
||||
const { prisma } = await importCumulativeFixture(
|
||||
cumulativeExportXml(
|
||||
"HKQuantityTypeIdentifierDistanceWalkingRunning",
|
||||
"mi",
|
||||
[{ value: 1.543, sourceName: "iPhone", hour: 8 }],
|
||||
),
|
||||
);
|
||||
|
||||
expect(prisma._measurements).toHaveLength(1);
|
||||
expect(prisma._measurements[0].value).toBeCloseTo(2483.217792, 6);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user