Something went wrong. Try again.
Convert CSV banking statements to hledger journals
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677import assert from "assert";import { Selection } from "./selection.js";
Deno.test("D12: a click selects a cell, and a second click unselects it", () => { const selection = new Selection(); selection.toggle(3, 1); assert.equal(selection.has(3, 1), true); assert.equal(selection.holds(3), true); selection.toggle(3, 1); assert.equal(selection.has(3, 1), false); assert.equal(selection.holds(3), false);});
Deno.test("D12: cells of one row are selected together", () => { const selection = new Selection(); selection.toggle(3, 1); selection.toggle(3, 2); assert.equal(selection.has(3, 1) && selection.has(3, 2), true);});
Deno.test("D12: a click in another row starts its selection over", () => { const selection = new Selection(); selection.toggle(3, 1); selection.toggle(4, 2); assert.equal(selection.has(3, 1), false); assert.equal(selection.holds(3), false); assert.equal(selection.has(4, 2), true); assert.equal(selection.has(4, 1), false);});
Deno.test("D12: a cell in the same column of another row is not selected", () => { const selection = new Selection(); selection.toggle(3, 1); assert.equal(selection.has(4, 1), false);});
Deno.test("D12: clear unselects every cell", () => { const selection = new Selection(); selection.toggle(3, 1); selection.clear(); assert.equal(selection.holds(3), false);});
const row = (number, status) => ({ row: number, status });
Deno.test("D12: the selection outlives a redraw that still shows its row unmatched", () => { const selection = new Selection(); selection.toggle(3, 1); selection.keep([row(2, "zero"), row(3, "zero")]); assert.equal(selection.has(3, 1), true);});
Deno.test("D12: the selection is dropped once its row is matched or not shown", () => { for (const rows of [[row(3, "one")], [row(2, "zero")]]) { const selection = new Selection(); selection.toggle(3, 1); selection.keep(rows); assert.equal(selection.holds(3), false); }});
const columns = new Map([ [0, { aliases: ["date"] }], [2, { aliases: ["payee", "counterparty"] }], [3, { aliases: ["memo"] }],]);
Deno.test("D12: selected cells give their clauses in column order, each under its column's first alias", () => { const selection = new Selection(); selection.toggle(3, 3); selection.toggle(3, 2); assert.deepEqual(selection.clauses(["01.10.", "x", "REWE 10/26", " Markt "], columns), [ "payee ~= /REWE 10.26/i", "memo ~= /Markt/i", ]);});