Something went wrong. Try again.
Convert CSV banking statements to hledger journals
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738import assert from "assert";import { previewOutcome, reasonFor, writeOutcome } from "./journal.js";
const problem = (message, row = null) => ({ message, row });
Deno.test("M1-UI-014: the reason a journal cannot be had is the first problem, with its row", () => { assert.equal(reasonFor([problem("matches no rule", 12), problem("later")]), "row 12: matches no rule");});
Deno.test("M1-UI-014: a reason on no row is only its message", () => { assert.equal(reasonFor([problem("no rules")]), "no rules");});
Deno.test("M1-UI-021: a refusal without a diagnostic still says so", () => { assert.equal(reasonFor([]), "no reason given");});
Deno.test("M1-UI-014: without a complete journal, the preview says why", () => { const preview = { journal: null, final: false, diagnostics: [problem("matches no rule", 2)] }; assert.equal(previewOutcome(preview), "no preview: row 2: matches no rule");});
Deno.test("M1-UI-014: a preview that could be written says so", () => { assert.equal(previewOutcome({ journal: "2026-09-11 x\n", final: true, diagnostics: [] }), "ready to write");});
Deno.test("M1-UI-014: a preview that is not final does not claim to be ready", () => { assert.equal(previewOutcome({ journal: "2026-09-11 x\n", final: false, diagnostics: [] }), "");});
Deno.test("M1-UI-021: a written journal says so", () => { assert.equal(writeOutcome(true, [problem("ignored")]), "written");});
Deno.test("M1-UI-021: a refused write says why", () => { assert.equal(writeOutcome(false, [problem("the journal already exists")]), "not written: the journal already exists");});