-
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.
feat(Bonus Pagamenti Digitali): [#176457237] Remove disabled account …
…from BPay found list (#2720) * [#176457237] remove disabled account from BPay list * [#176457237] fix import * [#176457237] add tests
- Loading branch information
1 parent
548ba06
commit d147418
Showing
3 changed files
with
148 additions
and
2 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
ts/features/wallet/onboarding/bancomatPay/store/reducers/__mock__/bpay.mock.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,19 @@ | ||
import { BPay } from "../../../../../../../../definitions/pagopa/BPay"; | ||
|
||
export const bPayAttMock: BPay = { | ||
bankName: "Bank Name", | ||
instituteCode: "123", | ||
numberObfuscated: "+3934*****123", | ||
paymentInstruments: [], | ||
serviceState: "ATT", | ||
uidHash: "uidHash" | ||
}; | ||
|
||
export const bPayDisMock: BPay = { | ||
bankName: "Bank Name", | ||
instituteCode: "123", | ||
numberObfuscated: "+3934*****123", | ||
paymentInstruments: [], | ||
serviceState: "DIS", | ||
uidHash: "uidHash" | ||
}; |
109 changes: 109 additions & 0 deletions
109
ts/features/wallet/onboarding/bancomatPay/store/reducers/__test__/foundBpay.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,109 @@ | ||
import { applicationChangeState } from "../../../../../../../store/actions/application"; | ||
import { appReducer } from "../../../../../../../store/reducers"; | ||
import { GlobalState } from "../../../../../../../store/reducers/types"; | ||
import { NetworkError } from "../../../../../../../utils/errors"; | ||
import { | ||
remoteError, | ||
remoteLoading, | ||
remoteReady, | ||
remoteUndefined | ||
} from "../../../../../../bonus/bpd/model/RemoteValue"; | ||
import { searchUserBPay } from "../../actions"; | ||
import { bPayAttMock, bPayDisMock } from "../__mock__/bpay.mock"; | ||
import { onboardingBPayFoundAccountsSelector } from "../foundBpay"; | ||
|
||
jest.mock("@react-native-community/async-storage", () => ({ | ||
AsyncStorage: jest.fn() | ||
})); | ||
|
||
jest.mock("react-native-share", () => ({ | ||
open: jest.fn() | ||
})); | ||
|
||
describe("test onboardingBPayFoundAccountsSelector", () => { | ||
const globalState: GlobalState = appReducer( | ||
undefined, | ||
applicationChangeState("active") | ||
); | ||
it("should return RemoteUndefined with the default state", () => { | ||
expect(onboardingBPayFoundAccountsSelector(globalState)).toBe( | ||
remoteUndefined | ||
); | ||
}); | ||
it("should return RemoteLoading after dispatch searchUserBPay.request", () => { | ||
const loadingState: GlobalState = appReducer( | ||
globalState, | ||
searchUserBPay.request(undefined) | ||
); | ||
|
||
expect(onboardingBPayFoundAccountsSelector(loadingState)).toBe( | ||
remoteLoading | ||
); | ||
}); | ||
it("should return RemoteError after dispatch searchUserBPay.failure", () => { | ||
const error: NetworkError = { kind: "timeout" }; | ||
|
||
const loadingState: GlobalState = appReducer( | ||
globalState, | ||
searchUserBPay.failure(error) | ||
); | ||
|
||
expect(onboardingBPayFoundAccountsSelector(loadingState)).toStrictEqual( | ||
remoteError(error) | ||
); | ||
}); | ||
it("should return remoteReady with a BPay serviceState===ATT", () => { | ||
const loadingState: GlobalState = appReducer( | ||
globalState, | ||
searchUserBPay.success([bPayAttMock]) | ||
); | ||
|
||
expect(onboardingBPayFoundAccountsSelector(loadingState)).toStrictEqual( | ||
remoteReady([bPayAttMock]) | ||
); | ||
}); | ||
it("should return remoteReady with an empty array if BPay serviceState===DIS", () => { | ||
const loadingState: GlobalState = appReducer( | ||
globalState, | ||
searchUserBPay.success([bPayDisMock]) | ||
); | ||
|
||
expect(onboardingBPayFoundAccountsSelector(loadingState)).toStrictEqual( | ||
remoteReady([]) | ||
); | ||
}); | ||
it("should return remoteReady with only BPay with serviceState!==DIS", () => { | ||
const loadingState: GlobalState = appReducer( | ||
globalState, | ||
searchUserBPay.success([bPayDisMock, bPayAttMock]) | ||
); | ||
|
||
expect(onboardingBPayFoundAccountsSelector(loadingState)).toStrictEqual( | ||
remoteReady([bPayAttMock]) | ||
); | ||
}); | ||
it("should return a BPay with a generic serviceState", () => { | ||
const unknownServiceState = { ...bPayAttMock, serviceState: "UNKNOWN" }; | ||
|
||
const loadingState: GlobalState = appReducer( | ||
globalState, | ||
searchUserBPay.success([unknownServiceState]) | ||
); | ||
|
||
expect(onboardingBPayFoundAccountsSelector(loadingState)).toStrictEqual( | ||
remoteReady([unknownServiceState]) | ||
); | ||
}); | ||
it("should return a BPay with an undefined serviceState", () => { | ||
const undefinedServiceState = { ...bPayAttMock, serviceState: undefined }; | ||
|
||
const loadingState: GlobalState = appReducer( | ||
globalState, | ||
searchUserBPay.success([undefinedServiceState]) | ||
); | ||
|
||
expect(onboardingBPayFoundAccountsSelector(loadingState)).toStrictEqual( | ||
remoteReady([undefinedServiceState]) | ||
); | ||
}); | ||
}); |
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