mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 22:26:13 +00:00
test(dawarich): pin the movement block, the channels and the mocks; document the connection
Covers the day section, the model projection without the travel country and the two correlation channels; the backup and correlation mocks learn the new delegate. Adds the operator page for DAWARICH_PRIVATE_ORIGINS and regenerates the API contract.
This commit is contained in:
1 parent
b99bcaeec6
commit
c03f79afd5
7 files changed
+372
-58
No files matched your search
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* "On the move" renders the server's values as they come and leaves out what
|
||||
* the day has no value for: a null is no coverage, never a zero.
|
||||
*/
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
|
||||
import { DayMovementSection } from "../day-movement";
|
||||
|
||||
function render(
|
||||
movement: Parameters<typeof DayMovementSection>[0]["movement"],
|
||||
) {
|
||||
return renderToStaticMarkup(
|
||||
<I18nProvider initialLocale="en">
|
||||
<DayMovementSection movement={movement} />
|
||||
</I18nProvider>,
|
||||
);
|
||||
}
|
||||
|
||||
const base = {
|
||||
source: "dawarich" as const,
|
||||
distance: { unit: "km" as const, total: 48.3, driving: 12, train: 0 },
|
||||
placesVisited: 4,
|
||||
awayFromHomeMinutes: 600,
|
||||
travel: { isTravelDay: true, countryCode: "ES" },
|
||||
fetchedAt: "2026-06-16T01:20:00.000Z",
|
||||
};
|
||||
|
||||
describe("DayMovementSection", () => {
|
||||
it("shows each value the day has", () => {
|
||||
const html = render(base);
|
||||
expect(html).toContain('data-movement="total"');
|
||||
expect(html).toContain("48.3 km");
|
||||
expect(html).toContain('data-movement="driving"');
|
||||
expect(html).toContain('data-movement="away"');
|
||||
expect(html).toContain("Spain");
|
||||
// No train that day: no row, rather than "0 km".
|
||||
expect(html).not.toContain('data-movement="train"');
|
||||
});
|
||||
|
||||
it("leaves out time away from home without coverage", () => {
|
||||
const html = render({
|
||||
...base,
|
||||
awayFromHomeMinutes: null,
|
||||
travel: null,
|
||||
});
|
||||
expect(html).not.toContain('data-movement="away"');
|
||||
expect(html).not.toContain('data-movement="travel"');
|
||||
});
|
||||
|
||||
it("renders nothing when the day has no value at all", () => {
|
||||
const html = render({
|
||||
...base,
|
||||
distance: { unit: "mi", total: null, driving: null, train: null },
|
||||
placesVisited: null,
|
||||
awayFromHomeMinutes: null,
|
||||
travel: null,
|
||||
});
|
||||
expect(html).toBe("");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user