test(folio): cover transition frames, card readings and creation

This commit is contained in:
pj committed 2026-08-14 16:33:11 +05:30
1 parent d31de3b247
commit 9efed1f669
5 files changed
+570 -35

No files matched your search

+15 -15
View File
@@ -5,35 +5,35 @@ import { readHomeTotalBalance } from "../../../examples/folio/sanderling/predica
test("on Home the app's own total is the reading, the carrier and fresh", () => {
assert.deepEqual(
readHomeTotalBalance({ onHome: true, totalText: "$30.00", previousCarrier: 0 }),
readHomeTotalBalance({ route: "home", totalText: "$30.00", previousCarrier: 0 }),
{ value: 3000, carrier: 3000, fresh: true },
);
});
test("off Home there is nothing to read, so the carrier is reported unchanged", () => {
assert.deepEqual(
readHomeTotalBalance({ onHome: false, totalText: undefined, previousCarrier: 3000 }),
readHomeTotalBalance({ route: "ledger", totalText: undefined, previousCarrier: 3000 }),
{ value: 3000, carrier: 3000, fresh: false },
);
});
test("off Home before any Home visit reports the null carrier, still not fresh", () => {
assert.deepEqual(
readHomeTotalBalance({ onHome: false, totalText: undefined, previousCarrier: null }),
readHomeTotalBalance({ route: "ledger", totalText: undefined, previousCarrier: null }),
{ value: null, carrier: null, fresh: false },
);
});
test("a negative total parses with its sign", () => {
assert.deepEqual(
readHomeTotalBalance({ onHome: true, totalText: "-$1,234.56", previousCarrier: 0 }),
readHomeTotalBalance({ route: "home", totalText: "-$1,234.56", previousCarrier: 0 }),
{ value: -123456, carrier: -123456, fresh: true },
);
});
test("a fresh Home total overrides whatever the carrier held", () => {
assert.deepEqual(
readHomeTotalBalance({ onHome: true, totalText: "$7.50", previousCarrier: 9999 }),
readHomeTotalBalance({ route: "home", totalText: "$7.50", previousCarrier: 9999 }),
{ value: 750, carrier: 750, fresh: true },
);
});
@@ -45,14 +45,14 @@ test("a fresh Home total overrides whatever the carrier held", () => {
// unreadable Home left every later step null.
test("an unreadable Home total reports null but leaves the carrier intact", () => {
assert.deepEqual(
readHomeTotalBalance({ onHome: true, totalText: undefined, previousCarrier: 3000 }),
readHomeTotalBalance({ route: "home", totalText: undefined, previousCarrier: 3000 }),
{ value: null, carrier: 3000, fresh: false },
);
});
test("a garbled Home total is unknown, not zero", () => {
assert.deepEqual(
readHomeTotalBalance({ onHome: true, totalText: "$", previousCarrier: 3000 }),
readHomeTotalBalance({ route: "home", totalText: "$", previousCarrier: 3000 }),
{ value: null, carrier: 3000, fresh: false },
);
});
@@ -60,17 +60,17 @@ test("a garbled Home total is unknown, not zero", () => {
test("an unreadable Home no longer poisons the steps after it", () => {
let carrier: number | null = null;
const seen: (number | null)[] = [];
const step = (onHome: boolean, totalText: string | undefined) => {
const reading = readHomeTotalBalance({ onHome, totalText, previousCarrier: carrier });
const step = (route: string | null, totalText: string | undefined) => {
const reading = readHomeTotalBalance({ route, totalText, previousCarrier: carrier });
carrier = reading.carrier;
seen.push(reading.value);
};
step(true, "$30.00");
step(true, undefined);
step(false, undefined);
step(false, undefined);
step(true, "$50.00");
step("home", "$30.00");
step("home", undefined);
step("ledger", undefined);
step("ledger", undefined);
step("home", "$50.00");
assert.deepEqual(seen, [3000, null, 3000, 3000, 5000]);
});
@@ -80,7 +80,7 @@ test("an unreadable Home no longer poisons the steps after it", () => {
// the viewport happens to fit.
test("Home total is one node, so an off-screen account cannot change it", () => {
const withFiveCards = readHomeTotalBalance({
onHome: true,
route: "home",
totalText: "$2,589.00",
previousCarrier: 0,
});