You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- package.json with jsdom devDep; npm test / npm run build scripts
- test/helpers: loadApp (script-tag injection), setupJsdom (preseeds wallet,
stubs fetch/Chart/canvas/scrollIntoView, returns teardown for clock interval)
- Guarded module.exports footers on 02-utils, 04b-lot-engine, 05-compute so
pure modules are require()-able from Node; no-op in browser
- 6 unit tests (lot-engine assigned-PUT/CALLED/CLOSED, compute netCost, fmt
precision, existing merge) and 2 jsdom integration tests (addTrade,
quickOutcome)
- Separate test CI job in .github/workflows/test.yml
- Docs updated: CLAUDE.md (Tests section, line counts, rule 6),
CONTRIBUTING.md, README.md
|`01a-outcomes.js`| 32 |`OUTCOMES` registry: per-outcome `{title, badgeClass, platforms}`. Single source of truth for outcome display data + picker membership. Lot-lifecycle effects live in the Lot Engine, not here |
|`04b-lot-engine.js`|136|`lotNetCost(costBasis, lotPremiums, size)` and `lotEngine(assetTrades)` → `{lots, portfolioPnl, portfolioPremiums, putOnlyPnl, tradeAccounting}`. **Single source of truth** for wheel invariants (see Lot model below). Pure; dual-exported for Node. **Key invariant:** assigned-PUT premium IS credited to the new lot's `lotPremiums`|
|`04b-lot-engine.js`|140|`lotNetCost(costBasis, lotPremiums, size)` and `lotEngine(assetTrades)` → `{lots, portfolioPnl, portfolioPremiums, putOnlyPnl, tradeAccounting}`. **Single source of truth** for wheel invariants (see Lot model below). Pure; dual-exported for Node. **Key invariant:** assigned-PUT premium IS credited to the new lot's `lotPremiums`|
47
+
|`05-compute.js`|89|`compute(assetFilter)` → `{streams, lots, allRows, displayRows}`. Cross-asset orchestrator: per-asset grouping, calls `lotEngine`, applies asset filter, sorts, assigns idx, derives display fields (`returnPct`, `monthly`, `annual`, `lotPnl`). Dual-exports `compute` for Node tests (reads `trades`/`lotEngine` from globals — set them before `require`) |
48
48
|`05a-merge-open-lots.js`| 113 |`mergeOpenLots(trades, asset)` → `trades'`. Pure helper that merges all open lots for one asset (size-weighted `costBasis`, summed `lotPremiums`, earliest opener kept, CALL `lotNum` cleared). Prefers `lotEngine`, falls back to `compute` or a HOLDING/ASSIGNED heuristic for Node tests |
49
49
|`06-render-table.js`| 452 |`sortOpen/sortHist`, `renderExpiryTable` (today badge + mobile cards), `fetchExpiryPrices` (CoinGecko, calls full `render()` on success), `rTable` (holdings cards, open & history tables, history filter application), `rStats` (just delegates to `renderExpiryTable`), `exportHistoryCSV` (downloads filtered history as CSV) |
0 commit comments