mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(folio): cover submit predicate with raw typed-amount inputs
Pipes realistic raw keystrokes through parseTypedAmount + the predicate so single submits clear and double submits fire as expected.
This commit is contained in:
1 parent
3e4cf965b0
commit
9647d5e042
1 file changed
+52
-1
@@ -1,7 +1,10 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
|
||||
import { submitChangesBalanceByTypedAmount } from "../../../examples/folio/sanderling/predicates.ts";
|
||||
import {
|
||||
parseTypedAmount,
|
||||
submitChangesBalanceByTypedAmount,
|
||||
} from "../../../examples/folio/sanderling/predicates.ts";
|
||||
|
||||
const submitOn = "testTag:LedgerScreen > testTag:TxnSubmit";
|
||||
|
||||
@@ -112,3 +115,51 @@ test("selector as object without TxnSubmit: vacuous true", () => {
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("raw whole-dollar input: single submit clears", () => {
|
||||
assert.equal(
|
||||
submitChangesBalanceByTypedAmount({
|
||||
lastAction: { kind: "Tap", on: submitOn },
|
||||
typedAmount: parseTypedAmount("50"),
|
||||
prevTotalBalance: 5000,
|
||||
currTotalBalance: 10000,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("raw whole-dollar input: double submit fires", () => {
|
||||
assert.equal(
|
||||
submitChangesBalanceByTypedAmount({
|
||||
lastAction: { kind: "Tap", on: submitOn },
|
||||
typedAmount: parseTypedAmount("50"),
|
||||
prevTotalBalance: 5000,
|
||||
currTotalBalance: 15000,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test("decimal input from empty prior balance clears", () => {
|
||||
assert.equal(
|
||||
submitChangesBalanceByTypedAmount({
|
||||
lastAction: { kind: "Tap", on: submitOn },
|
||||
typedAmount: parseTypedAmount("5.50"),
|
||||
prevTotalBalance: 0,
|
||||
currTotalBalance: 550,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("DoubleTap kind with raw whole-dollar input fires", () => {
|
||||
assert.equal(
|
||||
submitChangesBalanceByTypedAmount({
|
||||
lastAction: { kind: "DoubleTap", on: submitOn },
|
||||
typedAmount: parseTypedAmount("100"),
|
||||
prevTotalBalance: 0,
|
||||
currTotalBalance: 20000,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user