diff --git a/pkg/spec/test/folio-submit-balance-predicate.test.ts b/pkg/spec/test/folio-submit-balance-predicate.test.ts index d676d6c..90c0885 100644 --- a/pkg/spec/test/folio-submit-balance-predicate.test.ts +++ b/pkg/spec/test/folio-submit-balance-predicate.test.ts @@ -11,6 +11,7 @@ const submitOn = "testTag:LedgerScreen > testTag:TxnSubmit"; test("single submit: delta matches typed amount", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "Tap", on: submitOn }, typedAmount: 500, prevTotalBalance: 1000, @@ -23,6 +24,7 @@ test("single submit: delta matches typed amount", () => { test("double submit: delta is twice the typed amount, fires", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "Tap", on: submitOn }, typedAmount: 500, prevTotalBalance: 1000, @@ -35,6 +37,7 @@ test("double submit: delta is twice the typed amount, fires", () => { test("DoubleTap kind also caught when delta exceeds typed amount", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "DoubleTap", on: submitOn }, typedAmount: 500, prevTotalBalance: 0, @@ -47,6 +50,7 @@ test("DoubleTap kind also caught when delta exceeds typed amount", () => { test("wrong action kind: vacuous true even with mismatch", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "InputText", on: submitOn }, typedAmount: 500, prevTotalBalance: 1000, @@ -59,6 +63,7 @@ test("wrong action kind: vacuous true even with mismatch", () => { test("wrong target: vacuous true even with mismatch", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "Tap", on: "testTag:LoginScreen > testTag:LoginSubmit" }, typedAmount: 500, prevTotalBalance: 1000, @@ -71,6 +76,7 @@ test("wrong target: vacuous true even with mismatch", () => { test("null lastAction: vacuous true", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: null, typedAmount: 500, prevTotalBalance: 1000, @@ -83,6 +89,7 @@ test("null lastAction: vacuous true", () => { test("zero typedAmount: vacuous true", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "Tap", on: submitOn }, typedAmount: 0, prevTotalBalance: 1000, @@ -95,6 +102,7 @@ test("zero typedAmount: vacuous true", () => { test("selector as object: coerced safely and TxnSubmit detected", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "Tap", on: { testTag: "TxnSubmit" } }, typedAmount: 500, prevTotalBalance: 0, @@ -107,6 +115,7 @@ test("selector as object: coerced safely and TxnSubmit detected", () => { test("selector as object without TxnSubmit: vacuous true", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "Tap", on: { testTag: "LoginSubmit" } }, typedAmount: 500, prevTotalBalance: 0, @@ -119,6 +128,7 @@ test("selector as object without TxnSubmit: vacuous true", () => { test("raw whole-dollar input: single submit clears", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "Tap", on: submitOn }, typedAmount: parseTypedAmount("50"), prevTotalBalance: 5000, @@ -131,6 +141,7 @@ test("raw whole-dollar input: single submit clears", () => { test("raw whole-dollar input: double submit fires", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "Tap", on: submitOn }, typedAmount: parseTypedAmount("50"), prevTotalBalance: 5000, @@ -143,6 +154,7 @@ test("raw whole-dollar input: double submit fires", () => { test("decimal input from empty prior balance clears", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "Tap", on: submitOn }, typedAmount: parseTypedAmount("5.50"), prevTotalBalance: 0, @@ -155,6 +167,7 @@ test("decimal input from empty prior balance clears", () => { test("DoubleTap kind with raw whole-dollar input fires", () => { assert.equal( submitChangesBalanceByTypedAmount({ + route: "home", lastAction: { kind: "DoubleTap", on: submitOn }, typedAmount: parseTypedAmount("100"), prevTotalBalance: 0, @@ -163,3 +176,68 @@ test("DoubleTap kind with raw whole-dollar input fires", () => { false, ); }); + +test("route gate: ledger landing with stale carrier is skipped", () => { + assert.equal( + submitChangesBalanceByTypedAmount({ + route: "ledger", + lastAction: { kind: "Tap", on: submitOn }, + typedAmount: 5000, + prevTotalBalance: 0, + currTotalBalance: 0, + }), + true, + ); +}); + +test("route gate: add-transaction landing with double-submit delta is skipped", () => { + assert.equal( + submitChangesBalanceByTypedAmount({ + route: "add-transaction", + lastAction: { kind: "DoubleTap", on: submitOn }, + typedAmount: 5000, + prevTotalBalance: 0, + currTotalBalance: 10000, + }), + true, + ); +}); + +test("route gate: null route is skipped", () => { + assert.equal( + submitChangesBalanceByTypedAmount({ + route: null, + lastAction: { kind: "Tap", on: submitOn }, + typedAmount: 5000, + prevTotalBalance: 0, + currTotalBalance: 0, + }), + true, + ); +}); + +test("route gate: home landing with matching delta passes", () => { + assert.equal( + submitChangesBalanceByTypedAmount({ + route: "home", + lastAction: { kind: "Tap", on: submitOn }, + typedAmount: 5000, + prevTotalBalance: 0, + currTotalBalance: 5000, + }), + true, + ); +}); + +test("route gate: home landing with double-insert delta fires", () => { + assert.equal( + submitChangesBalanceByTypedAmount({ + route: "home", + lastAction: { kind: "Tap", on: submitOn }, + typedAmount: 5000, + prevTotalBalance: 0, + currTotalBalance: 10000, + }), + false, + ); +});