mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(spec): cover route gate in submit-balance predicate
Adds route arg to existing cases (all use "home") and adds five new cases: ledger landing with stale carrier, add-transaction with double-insert delta, null route, plus home-landing positive and double-insert negative cases anchoring the gate's allow path.
This commit is contained in:
1 parent
4c7c22ced6
commit
37eceed674
1 file changed
+78
@@ -11,6 +11,7 @@ const submitOn = "testTag:LedgerScreen > testTag:TxnSubmit";
|
|||||||
test("single submit: delta matches typed amount", () => {
|
test("single submit: delta matches typed amount", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "Tap", on: submitOn },
|
lastAction: { kind: "Tap", on: submitOn },
|
||||||
typedAmount: 500,
|
typedAmount: 500,
|
||||||
prevTotalBalance: 1000,
|
prevTotalBalance: 1000,
|
||||||
@@ -23,6 +24,7 @@ test("single submit: delta matches typed amount", () => {
|
|||||||
test("double submit: delta is twice the typed amount, fires", () => {
|
test("double submit: delta is twice the typed amount, fires", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "Tap", on: submitOn },
|
lastAction: { kind: "Tap", on: submitOn },
|
||||||
typedAmount: 500,
|
typedAmount: 500,
|
||||||
prevTotalBalance: 1000,
|
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", () => {
|
test("DoubleTap kind also caught when delta exceeds typed amount", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "DoubleTap", on: submitOn },
|
lastAction: { kind: "DoubleTap", on: submitOn },
|
||||||
typedAmount: 500,
|
typedAmount: 500,
|
||||||
prevTotalBalance: 0,
|
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", () => {
|
test("wrong action kind: vacuous true even with mismatch", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "InputText", on: submitOn },
|
lastAction: { kind: "InputText", on: submitOn },
|
||||||
typedAmount: 500,
|
typedAmount: 500,
|
||||||
prevTotalBalance: 1000,
|
prevTotalBalance: 1000,
|
||||||
@@ -59,6 +63,7 @@ test("wrong action kind: vacuous true even with mismatch", () => {
|
|||||||
test("wrong target: vacuous true even with mismatch", () => {
|
test("wrong target: vacuous true even with mismatch", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "Tap", on: "testTag:LoginScreen > testTag:LoginSubmit" },
|
lastAction: { kind: "Tap", on: "testTag:LoginScreen > testTag:LoginSubmit" },
|
||||||
typedAmount: 500,
|
typedAmount: 500,
|
||||||
prevTotalBalance: 1000,
|
prevTotalBalance: 1000,
|
||||||
@@ -71,6 +76,7 @@ test("wrong target: vacuous true even with mismatch", () => {
|
|||||||
test("null lastAction: vacuous true", () => {
|
test("null lastAction: vacuous true", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: null,
|
lastAction: null,
|
||||||
typedAmount: 500,
|
typedAmount: 500,
|
||||||
prevTotalBalance: 1000,
|
prevTotalBalance: 1000,
|
||||||
@@ -83,6 +89,7 @@ test("null lastAction: vacuous true", () => {
|
|||||||
test("zero typedAmount: vacuous true", () => {
|
test("zero typedAmount: vacuous true", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "Tap", on: submitOn },
|
lastAction: { kind: "Tap", on: submitOn },
|
||||||
typedAmount: 0,
|
typedAmount: 0,
|
||||||
prevTotalBalance: 1000,
|
prevTotalBalance: 1000,
|
||||||
@@ -95,6 +102,7 @@ test("zero typedAmount: vacuous true", () => {
|
|||||||
test("selector as object: coerced safely and TxnSubmit detected", () => {
|
test("selector as object: coerced safely and TxnSubmit detected", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "Tap", on: { testTag: "TxnSubmit" } },
|
lastAction: { kind: "Tap", on: { testTag: "TxnSubmit" } },
|
||||||
typedAmount: 500,
|
typedAmount: 500,
|
||||||
prevTotalBalance: 0,
|
prevTotalBalance: 0,
|
||||||
@@ -107,6 +115,7 @@ test("selector as object: coerced safely and TxnSubmit detected", () => {
|
|||||||
test("selector as object without TxnSubmit: vacuous true", () => {
|
test("selector as object without TxnSubmit: vacuous true", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "Tap", on: { testTag: "LoginSubmit" } },
|
lastAction: { kind: "Tap", on: { testTag: "LoginSubmit" } },
|
||||||
typedAmount: 500,
|
typedAmount: 500,
|
||||||
prevTotalBalance: 0,
|
prevTotalBalance: 0,
|
||||||
@@ -119,6 +128,7 @@ test("selector as object without TxnSubmit: vacuous true", () => {
|
|||||||
test("raw whole-dollar input: single submit clears", () => {
|
test("raw whole-dollar input: single submit clears", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "Tap", on: submitOn },
|
lastAction: { kind: "Tap", on: submitOn },
|
||||||
typedAmount: parseTypedAmount("50"),
|
typedAmount: parseTypedAmount("50"),
|
||||||
prevTotalBalance: 5000,
|
prevTotalBalance: 5000,
|
||||||
@@ -131,6 +141,7 @@ test("raw whole-dollar input: single submit clears", () => {
|
|||||||
test("raw whole-dollar input: double submit fires", () => {
|
test("raw whole-dollar input: double submit fires", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "Tap", on: submitOn },
|
lastAction: { kind: "Tap", on: submitOn },
|
||||||
typedAmount: parseTypedAmount("50"),
|
typedAmount: parseTypedAmount("50"),
|
||||||
prevTotalBalance: 5000,
|
prevTotalBalance: 5000,
|
||||||
@@ -143,6 +154,7 @@ test("raw whole-dollar input: double submit fires", () => {
|
|||||||
test("decimal input from empty prior balance clears", () => {
|
test("decimal input from empty prior balance clears", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "Tap", on: submitOn },
|
lastAction: { kind: "Tap", on: submitOn },
|
||||||
typedAmount: parseTypedAmount("5.50"),
|
typedAmount: parseTypedAmount("5.50"),
|
||||||
prevTotalBalance: 0,
|
prevTotalBalance: 0,
|
||||||
@@ -155,6 +167,7 @@ test("decimal input from empty prior balance clears", () => {
|
|||||||
test("DoubleTap kind with raw whole-dollar input fires", () => {
|
test("DoubleTap kind with raw whole-dollar input fires", () => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
submitChangesBalanceByTypedAmount({
|
submitChangesBalanceByTypedAmount({
|
||||||
|
route: "home",
|
||||||
lastAction: { kind: "DoubleTap", on: submitOn },
|
lastAction: { kind: "DoubleTap", on: submitOn },
|
||||||
typedAmount: parseTypedAmount("100"),
|
typedAmount: parseTypedAmount("100"),
|
||||||
prevTotalBalance: 0,
|
prevTotalBalance: 0,
|
||||||
@@ -163,3 +176,68 @@ test("DoubleTap kind with raw whole-dollar input fires", () => {
|
|||||||
false,
|
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,
|
||||||
|
);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user