-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/primer-io/primer-sdk-reac…
…t-native into feat/ACC-3019-ACC-3020-ACC-3022/ACH-react-native-android-and-shared-code
- Loading branch information
Showing
36 changed files
with
1,740 additions
and
158 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
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
224 changes: 155 additions & 69 deletions
224
packages/example/ios/example_0_70_6.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
.../example/ios/example_0_70_6.xcodeproj/xcshareddata/xcschemes/example_0_70_6Tests.xcscheme
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
91 changes: 91 additions & 0 deletions
91
...os/example_0_70_6Tests/DataModelsTests/Banks Component/RNTBanksCollectableDataTests.swift
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,91 @@ | ||
// | ||
// RNTBanksCollectableDataTests.swift | ||
// example_0_70_6Tests | ||
// | ||
// Created by Boris on 23.5.24.. | ||
// | ||
|
||
import XCTest | ||
@testable import primer_io_react_native | ||
import PrimerSDK | ||
|
||
class BanksCollectableDataRNTests: XCTestCase { | ||
|
||
func testFilterRNInitialization() { | ||
let filter = FilterRN(text: "filterText") | ||
XCTAssertEqual(filter.validatableDataName, "bankListFilter") | ||
XCTAssertEqual(filter.text, "filterText") | ||
} | ||
|
||
func testBankIdRNInitialization() { | ||
let bankId = BankIdRN(id: "bankId123") | ||
XCTAssertEqual(bankId.validatableDataName, "bankId") | ||
XCTAssertEqual(bankId.id, "bankId123") | ||
} | ||
|
||
func testBanksCollectableDataToBankIdRN() { | ||
let bankData = BanksCollectableData.bankId(bankId: "bankId123") | ||
|
||
if case let .bankId(bankId) = bankData { | ||
let bankIdRN = BankIdRN(id: bankId) | ||
XCTAssertEqual(bankIdRN.validatableDataName, "bankId") | ||
XCTAssertEqual(bankIdRN.id, "bankId123") | ||
} else { | ||
XCTFail("Conversion to BankIdRN failed") | ||
} | ||
} | ||
|
||
func testBanksCollectableDataToFilterRN() { | ||
let filterData = BanksCollectableData.bankFilterText(text: "filterText") | ||
|
||
if case let .bankFilterText(text) = filterData { | ||
let filterRN = FilterRN(text: text) | ||
XCTAssertEqual(filterRN.validatableDataName, "bankListFilter") | ||
XCTAssertEqual(filterRN.text, "filterText") | ||
} else { | ||
XCTFail("Conversion to FilterRN failed") | ||
} | ||
} | ||
|
||
func testFilterRNEncoding() { | ||
let filter = FilterRN(text: "filterText") | ||
let encoder = JSONEncoder() | ||
do { | ||
let data = try encoder.encode(filter) | ||
let jsonString = String(data: data, encoding: .utf8) | ||
XCTAssertNotNil(jsonString) | ||
} catch { | ||
XCTFail("Encoding failed: \(error)") | ||
} | ||
} | ||
|
||
func testBankIdRNEncoding() { | ||
let bankId = BankIdRN(id: "bankId123") | ||
let encoder = JSONEncoder() | ||
do { | ||
let data = try encoder.encode(bankId) | ||
let jsonString = String(data: data, encoding: .utf8) | ||
XCTAssertNotNil(jsonString) | ||
} catch { | ||
XCTFail("Encoding failed: \(error)") | ||
} | ||
} | ||
|
||
func testBanksCollectableDataEncoding() { | ||
let bankIdData = BanksCollectableData.bankId(bankId: "bankId123") | ||
let filterData = BanksCollectableData.bankFilterText(text: "filterText") | ||
let encoder = JSONEncoder() | ||
|
||
do { | ||
let bankIdDataEncoded = try encoder.encode(bankIdData) | ||
let bankIdJsonString = String(data: bankIdDataEncoded, encoding: .utf8) | ||
XCTAssertNotNil(bankIdJsonString) | ||
|
||
let filterDataEncoded = try encoder.encode(filterData) | ||
let filterJsonString = String(data: filterDataEncoded, encoding: .utf8) | ||
XCTAssertNotNil(filterJsonString) | ||
} catch { | ||
XCTFail("Encoding failed: \(error)") | ||
} | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
packages/example/ios/example_0_70_6Tests/DataModelsTests/ImplementedRNCallbacksTests.swift
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,116 @@ | ||
// | ||
// ImplementedRNCallbacksTests.swift | ||
// example_0_70_6Tests | ||
// | ||
// Created by Boris on 20.5.24.. | ||
// | ||
|
||
import XCTest | ||
@testable import primer_io_react_native | ||
|
||
class ImplementedRNCallbacksTests: XCTestCase { | ||
|
||
func testDecodingWithAllFields() { | ||
let jsonString = """ | ||
{ | ||
"onAvailablePaymentMethodsLoad": true, | ||
"onTokenizationStart": true, | ||
"onTokenizationSuccess": true, | ||
"onCheckoutResume": true, | ||
"onCheckoutPending": true, | ||
"onCheckoutAdditionalInfo": true, | ||
"onError": true, | ||
"onCheckoutComplete": true, | ||
"onBeforeClientSessionUpdate": true, | ||
"onClientSessionUpdate": true, | ||
"onBeforePaymentCreate": true, | ||
"onPreparationStart": true, | ||
"onPaymentMethodShow": true, | ||
"onDismiss": true | ||
} | ||
""" | ||
let jsonData = jsonString.data(using: .utf8)! | ||
let decoder = JSONDecoder() | ||
|
||
do { | ||
let callbacks = try decoder.decode(ImplementedRNCallbacks.self, from: jsonData) | ||
|
||
XCTAssertTrue(callbacks.isOnAvailablePaymentMethodsLoadImplemented) | ||
XCTAssertTrue(callbacks.isOnTokenizationStartImplemented) | ||
XCTAssertTrue(callbacks.isOnTokenizationSuccessImplemented) | ||
XCTAssertTrue(callbacks.isOnCheckoutResumeImplemented) | ||
XCTAssertTrue(callbacks.isOnCheckoutPendingImplemented) | ||
XCTAssertTrue(callbacks.isOnCheckoutAdditionalInfoImplemented) | ||
XCTAssertTrue(callbacks.isOnErrorImplemented) | ||
XCTAssertTrue(callbacks.isOnCheckoutCompleteImplemented) | ||
XCTAssertTrue(callbacks.isOnBeforeClientSessionUpdateImplemented) | ||
XCTAssertTrue(callbacks.isOnClientSessionUpdateImplemented) | ||
XCTAssertTrue(callbacks.isOnBeforePaymentCreateImplemented) | ||
XCTAssertTrue(callbacks.isOnPreparationStartImplemented) | ||
XCTAssertTrue(callbacks.isOnPaymentMethodShowImplemented) | ||
XCTAssertTrue(callbacks.isOnDismissImplemented) | ||
} catch { | ||
XCTFail("Decoding failed: \(error)") | ||
} | ||
} | ||
|
||
func testDecodingWithMissingFields() { | ||
let jsonString = """ | ||
{ | ||
"onTokenizationSuccess": true, | ||
"onCheckoutComplete": true, | ||
"onBeforeClientSessionUpdate": true | ||
} | ||
""" | ||
let jsonData = jsonString.data(using: .utf8)! | ||
let decoder = JSONDecoder() | ||
|
||
do { | ||
let callbacks = try decoder.decode(ImplementedRNCallbacks.self, from: jsonData) | ||
|
||
XCTAssertFalse(callbacks.isOnAvailablePaymentMethodsLoadImplemented) | ||
XCTAssertFalse(callbacks.isOnTokenizationStartImplemented) | ||
XCTAssertTrue(callbacks.isOnTokenizationSuccessImplemented) | ||
XCTAssertFalse(callbacks.isOnCheckoutResumeImplemented) | ||
XCTAssertFalse(callbacks.isOnCheckoutPendingImplemented) | ||
XCTAssertFalse(callbacks.isOnCheckoutAdditionalInfoImplemented) | ||
XCTAssertFalse(callbacks.isOnErrorImplemented) | ||
XCTAssertTrue(callbacks.isOnCheckoutCompleteImplemented) | ||
XCTAssertTrue(callbacks.isOnBeforeClientSessionUpdateImplemented) | ||
XCTAssertFalse(callbacks.isOnClientSessionUpdateImplemented) | ||
XCTAssertFalse(callbacks.isOnBeforePaymentCreateImplemented) | ||
XCTAssertFalse(callbacks.isOnPreparationStartImplemented) | ||
XCTAssertFalse(callbacks.isOnPaymentMethodShowImplemented) | ||
XCTAssertFalse(callbacks.isOnDismissImplemented) | ||
} catch { | ||
XCTFail("Decoding failed: \(error)") | ||
} | ||
} | ||
|
||
func testDecodingWithEmptyJSON() { | ||
let jsonString = "{}" | ||
let jsonData = jsonString.data(using: .utf8)! | ||
let decoder = JSONDecoder() | ||
|
||
do { | ||
let callbacks = try decoder.decode(ImplementedRNCallbacks.self, from: jsonData) | ||
|
||
XCTAssertFalse(callbacks.isOnAvailablePaymentMethodsLoadImplemented) | ||
XCTAssertFalse(callbacks.isOnTokenizationStartImplemented) | ||
XCTAssertFalse(callbacks.isOnTokenizationSuccessImplemented) | ||
XCTAssertFalse(callbacks.isOnCheckoutResumeImplemented) | ||
XCTAssertFalse(callbacks.isOnCheckoutPendingImplemented) | ||
XCTAssertFalse(callbacks.isOnCheckoutAdditionalInfoImplemented) | ||
XCTAssertFalse(callbacks.isOnErrorImplemented) | ||
XCTAssertFalse(callbacks.isOnCheckoutCompleteImplemented) | ||
XCTAssertFalse(callbacks.isOnBeforeClientSessionUpdateImplemented) | ||
XCTAssertFalse(callbacks.isOnClientSessionUpdateImplemented) | ||
XCTAssertFalse(callbacks.isOnBeforePaymentCreateImplemented) | ||
XCTAssertFalse(callbacks.isOnPreparationStartImplemented) | ||
XCTAssertFalse(callbacks.isOnPaymentMethodShowImplemented) | ||
XCTAssertFalse(callbacks.isOnDismissImplemented) | ||
} catch { | ||
XCTFail("Decoding failed: \(error)") | ||
} | ||
} | ||
} |
Oops, something went wrong.