-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Bonus Pagamenti Digitali): [#176129361] Cashback payment method. …
…Change footer buttons logic (#2592) * [#176129361] change label review footer button enabling login * [#176129361] update comment * [#176129361] update * [#176129361] update comments * [#176129361] add tests
- Loading branch information
1 parent
cd57293
commit 187fa70
Showing
5 changed files
with
225 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
ts/features/bonus/bpd/store/reducers/details/__test__/paymentMethods.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import * as pot from "italia-ts-commons/lib/pot"; | ||
import { | ||
areAnyPaymentMethodsActiveSelector, | ||
BpdPotPaymentMethodActivation | ||
} from "../paymentMethods"; | ||
import { IndexedById } from "../../../../../../../store/helpers/indexer"; | ||
import { HPan } from "../../../actions/paymentMethods"; | ||
import { fromPatchedWalletV2ToRawPaymentMethod } from "../../../../../../../utils/walletv2"; | ||
import { bancomat } from "../../__mock__/bancomat"; | ||
import { BancomatPaymentMethod } from "../../../../../../../types/pagopa"; | ||
|
||
const indexedPaymentMethods: IndexedById<BpdPotPaymentMethodActivation> = { | ||
id1: pot.some({ | ||
hPan: "hpan1" as HPan, | ||
activationStatus: "active" | ||
}), | ||
id2: pot.some({ | ||
hPan: "hpan2" as HPan, | ||
activationStatus: "active" | ||
}), | ||
id3: pot.some({ | ||
hPan: "hpan2" as HPan, | ||
activationStatus: "active" | ||
}) | ||
}; | ||
|
||
const paymentMethod = fromPatchedWalletV2ToRawPaymentMethod( | ||
bancomat | ||
) as BancomatPaymentMethod; | ||
const paymentMethodBancomat = { | ||
...paymentMethod, | ||
info: { ...paymentMethod.info, hashPan: "id1" } | ||
}; | ||
|
||
describe("payment methods reducer tests", () => { | ||
it("should return false since no methods are provided", () => { | ||
expect( | ||
areAnyPaymentMethodsActiveSelector([]).resultFunc(indexedPaymentMethods) | ||
).toBeFalsy(); | ||
}); | ||
|
||
it("should return true (id1 - active)", () => { | ||
expect( | ||
areAnyPaymentMethodsActiveSelector([paymentMethodBancomat]).resultFunc( | ||
indexedPaymentMethods | ||
) | ||
).toBeTruthy(); | ||
}); | ||
|
||
it("should return false (id1 - not active)", () => { | ||
expect( | ||
areAnyPaymentMethodsActiveSelector([paymentMethodBancomat]).resultFunc({ | ||
...indexedPaymentMethods, | ||
id1: pot.some({ | ||
hPan: "hpan1" as HPan, | ||
activationStatus: "inactive" | ||
}) | ||
}) | ||
).toBeFalsy(); | ||
}); | ||
|
||
it("should return true, even if in error (some error)", () => { | ||
expect( | ||
areAnyPaymentMethodsActiveSelector([paymentMethodBancomat]).resultFunc({ | ||
...indexedPaymentMethods, | ||
id1: pot.toError( | ||
pot.some({ | ||
hPan: "hpan1" as HPan, | ||
activationStatus: "active" | ||
}), | ||
new Error("some error") | ||
) | ||
}) | ||
).toBeTruthy(); | ||
}); | ||
|
||
it("should return false (none error)", () => { | ||
expect( | ||
areAnyPaymentMethodsActiveSelector([paymentMethodBancomat]).resultFunc({ | ||
...indexedPaymentMethods, | ||
id1: pot.toError(pot.none, new Error("some error")) | ||
}) | ||
).toBeFalsy(); | ||
}); | ||
|
||
it("should return true (at least one active)", () => { | ||
const indexedPaymentMethodsOneActive: IndexedById<BpdPotPaymentMethodActivation> = { | ||
id1: pot.some({ | ||
hPan: "hpan1" as HPan, | ||
activationStatus: "active" | ||
}), | ||
id2: pot.some({ | ||
hPan: "hpan2" as HPan, | ||
activationStatus: "inactive" | ||
}), | ||
id3: pot.some({ | ||
hPan: "hpan2" as HPan, | ||
activationStatus: "notActivable" | ||
}), | ||
id4: pot.none | ||
}; | ||
expect( | ||
areAnyPaymentMethodsActiveSelector([paymentMethodBancomat]).resultFunc( | ||
indexedPaymentMethodsOneActive | ||
) | ||
).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters