From 7b7d051edd6da0ad9f22066f19d164fb23e3287b Mon Sep 17 00:00:00 2001 From: PJ Date: Mon, 27 Apr 2026 00:03:48 +0700 Subject: [PATCH] refactor(folio-spec): use keyedBy for ledger row identity --- examples/folio/sanderling/spec.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/folio/sanderling/spec.ts b/examples/folio/sanderling/spec.ts index b526bdf..72f140b 100644 --- a/examples/folio/sanderling/spec.ts +++ b/examples/folio/sanderling/spec.ts @@ -5,6 +5,7 @@ import { always, extract, from, + keyedBy, next, now, weighted, @@ -48,12 +49,10 @@ const accounts = extract(s => // Ledger rows: identity composed from the row's stable testTag'd cells. const ledgerRows = extract(s => - s.ax.findAll([{ testTag: "LedgerScreen" }, { testTag: "LedgerRow" }]).map(row => { - const note = row.find({ testTag: "TxnNote" })?.text ?? ""; - const date = row.find({ testTag: "TxnDate" })?.text ?? ""; - const amount = row.find({ testTag: "TxnAmount" })?.text ?? ""; - return { key: `${date}|${note}|${amount}`, signed: parseDollarCents(amount) }; - })); + s.ax.findAll([{ testTag: "LedgerScreen" }, { testTag: "LedgerRow" }]).map(row => ({ + key: keyedBy(row, ["TxnDate", "TxnNote", "TxnAmount"]), + signed: parseDollarCents(row.find({ testTag: "TxnAmount" })?.text), + }))); const ledgerBalance = extract(s => parseDollarCents(s.ax.find({ testTag: "LedgerBalance" })?.text));