mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(verifier): wire longPresses and scrolls generators
This commit is contained in:
1 parent
2397a65b9f
commit
dc0026ad37
3 files changed
+116
-50
No files matched your search
@@ -1,42 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
|
||||
import {
|
||||
balanceMatchesAddedSum,
|
||||
type LedgerRow,
|
||||
} from "../../../examples/folio/sanderling/predicates.ts";
|
||||
|
||||
function row(key: string, signed: number): LedgerRow {
|
||||
return { key, signed };
|
||||
}
|
||||
|
||||
test("single new row whose signed amount matches the balance delta holds", () => {
|
||||
const previous: LedgerRow[] = [row("a", 100)];
|
||||
const current: LedgerRow[] = [row("a", 100), row("b", 500)];
|
||||
assert.equal(balanceMatchesAddedSum(previous, current, 100, 600), true);
|
||||
});
|
||||
|
||||
test("two new rows whose sum matches the balance delta holds", () => {
|
||||
const previous: LedgerRow[] = [];
|
||||
const current: LedgerRow[] = [row("a", 500), row("b", 300)];
|
||||
assert.equal(balanceMatchesAddedSum(previous, current, 0, 800), true);
|
||||
});
|
||||
|
||||
test("double-submit case: two identical rows with sum exceeding the delta violates", () => {
|
||||
const previous: LedgerRow[] = [];
|
||||
const current: LedgerRow[] = [row("a", 500), row("b", 500)];
|
||||
assert.equal(balanceMatchesAddedSum(previous, current, 0, 500), false);
|
||||
});
|
||||
|
||||
test("partial-credit case: two new rows whose sum falls short of the delta violates", () => {
|
||||
const previous: LedgerRow[] = [];
|
||||
const current: LedgerRow[] = [row("a", 200), row("b", 100)];
|
||||
assert.equal(balanceMatchesAddedSum(previous, current, 0, 500), false);
|
||||
});
|
||||
|
||||
test("no new rows holds vacuously regardless of balance delta", () => {
|
||||
const previous: LedgerRow[] = [row("a", 100)];
|
||||
const current: LedgerRow[] = [row("a", 100)];
|
||||
assert.equal(balanceMatchesAddedSum(previous, current, 100, 100), true);
|
||||
assert.equal(balanceMatchesAddedSum(previous, current, 100, 999), true);
|
||||
});
|
||||
Reference in new issue
Block a user