Something went wrong. Try again.
Convert CSV banking statements to hledger journals
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960import assert from "assert";import { cornerState, countText, where } from "./problems.js";
// A diagnostic as the state payload carries it, with no location at all.const nowhere = { file: null, journal: null, key: null, message: "m", posting: null, row: null, transaction: null,};const at = (location) => ({ ...nowhere, ...location });
Deno.test("M1-UI-012: a problem names its file and physical row", () => { assert.equal(where(at({ file: "2024.csv", row: 7 })), "2024.csv:7");});
Deno.test("M1-UI-012: a problem in a file but on no row names the file", () => { assert.equal(where(at({ file: "2024.csv" })), "2024.csv");});
Deno.test("M1-UI-013: a problem names the approved journal it was compared with", () => { assert.equal(where(at({ file: "2024.csv", row: 3, journal: "2024.journal" })), "2024.csv:3 ↔ 2024.journal");});
Deno.test("M1-UI-011: a problem in the configuration names its key", () => { assert.equal(where(at({ file: "rules.yaml", key: "rules[2].match" })), "rules.yaml [rules[2].match]");});
Deno.test("M1-UI-013: a structural difference names its transaction and posting", () => { assert.equal(where(at({ transaction: 4 })), "transaction 4"); assert.equal(where(at({ transaction: 4, posting: 1 })), "transaction 4 posting 1");});
Deno.test("M1-UI-013: the first transaction and posting are named like any other", () => { assert.equal(where(at({ transaction: 0, posting: 0 })), "transaction 0 posting 0");});
Deno.test("M1-UI-011: a problem with no location says nothing about where", () => { assert.equal(where(nowhere), "");});
Deno.test("D11: the corner counts problems in words", () => { assert.equal(countText(1), "1 problem"); assert.equal(countText(2), "2 problems"); assert.equal(countText(0), "0 problems");});
Deno.test("D11: with no problems the corner is empty, whether or not the panel was open", () => { assert.equal(cornerState(0, true), "none"); assert.equal(cornerState(0, false), "none");});
Deno.test("D11: with problems the corner is as it was last chosen", () => { assert.equal(cornerState(3, true), "open"); assert.equal(cornerState(3, false), "minimized");});