Skip to content

Commit

Permalink
Add more UNIT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisNikolic committed May 23, 2024
1 parent 6ed8559 commit 0c9056e
Show file tree
Hide file tree
Showing 21 changed files with 1,144 additions and 171 deletions.
76 changes: 72 additions & 4 deletions packages/example/ios/example_0_70_6.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
A17A44A32BF7A57F00433548 /* UIImageExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44A02BF7A57F00433548 /* UIImageExtensionTests.swift */; };
A17A44A42BF7A57F00433548 /* CodableExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44A12BF7A57F00433548 /* CodableExtensionsTests.swift */; };
A17A44A52BF7A57F00433548 /* ErrorExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44A22BF7A57F00433548 /* ErrorExtensionTests.swift */; };
A17A44A72BFB7A6200433548 /* PrimerCheckoutPaymentMethodTypeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44A62BFB7A6200433548 /* PrimerCheckoutPaymentMethodTypeTests.swift */; };
A17A44A92BFB7D3800433548 /* RNTPrimerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44A82BFB7D3800433548 /* RNTPrimerTests.swift */; };
A17A44AD2BFB843F00433548 /* ImplementedRNCallbacksTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44AC2BFB843F00433548 /* ImplementedRNCallbacksTests.swift */; };
A17A44B02BFB851900433548 /* PrimerBancontactCardRedirectData+ExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44AF2BFB851900433548 /* PrimerBancontactCardRedirectData+ExtensionTests.swift */; };
A17A44B22BFB858D00433548 /* PrimerCardData+ExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44B12BFB858D00433548 /* PrimerCardData+ExtensionTests.swift */; };
A17A44B42BFB865300433548 /* PrimerPhoneNumberData+ExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44B32BFB865300433548 /* PrimerPhoneNumberData+ExtensionTests.swift */; };
A17A44B62BFB86D700433548 /* PrimerRawRetailerData+ExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44B52BFB86D700433548 /* PrimerRawRetailerData+ExtensionTests.swift */; };
A17A44B82BFB874600433548 /* PrimerSettings+ExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44B72BFB874600433548 /* PrimerSettings+ExtensionsTests.swift */; };
A17A44BA2BFB8AD200433548 /* PrimerThemeRNTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44B92BFB8AD200433548 /* PrimerThemeRNTests.swift */; };
A17A44BC2BFB8C7B00433548 /* RNTNativeErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44BB2BFB8C7B00433548 /* RNTNativeErrorTests.swift */; };
A17A44C02BFF650A00433548 /* RNTBanksCollectableDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A17A44BF2BFF650A00433548 /* RNTBanksCollectableDataTests.swift */; };
C010C35792AF87095495BFED /* (null) in Frameworks */ = {isa = PBXBuildFile; };
CA8BCC075C44D2D84D0763C5 /* libPods-example_0_70_6-example_0_70_6Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CD0A4D74B8ACFC62D6A65A1 /* libPods-example_0_70_6-example_0_70_6Tests.a */; };
EBD12C17BEFC44D84D486A26 /* libPods-example_0_70_6.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 80FB55FEE50456A2CC839A71 /* libPods-example_0_70_6.a */; };
Expand Down Expand Up @@ -55,6 +66,17 @@
A17A44A02BF7A57F00433548 /* UIImageExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageExtensionTests.swift; sourceTree = "<group>"; };
A17A44A12BF7A57F00433548 /* CodableExtensionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodableExtensionsTests.swift; sourceTree = "<group>"; };
A17A44A22BF7A57F00433548 /* ErrorExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorExtensionTests.swift; sourceTree = "<group>"; };
A17A44A62BFB7A6200433548 /* PrimerCheckoutPaymentMethodTypeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimerCheckoutPaymentMethodTypeTests.swift; sourceTree = "<group>"; };
A17A44A82BFB7D3800433548 /* RNTPrimerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNTPrimerTests.swift; sourceTree = "<group>"; };
A17A44AC2BFB843F00433548 /* ImplementedRNCallbacksTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImplementedRNCallbacksTests.swift; sourceTree = "<group>"; };
A17A44AF2BFB851900433548 /* PrimerBancontactCardRedirectData+ExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimerBancontactCardRedirectData+ExtensionTests.swift"; sourceTree = "<group>"; };
A17A44B12BFB858D00433548 /* PrimerCardData+ExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimerCardData+ExtensionTests.swift"; sourceTree = "<group>"; };
A17A44B32BFB865300433548 /* PrimerPhoneNumberData+ExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimerPhoneNumberData+ExtensionTests.swift"; sourceTree = "<group>"; };
A17A44B52BFB86D700433548 /* PrimerRawRetailerData+ExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimerRawRetailerData+ExtensionTests.swift"; sourceTree = "<group>"; };
A17A44B72BFB874600433548 /* PrimerSettings+ExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrimerSettings+ExtensionsTests.swift"; sourceTree = "<group>"; };
A17A44B92BFB8AD200433548 /* PrimerThemeRNTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimerThemeRNTests.swift; sourceTree = "<group>"; };
A17A44BB2BFB8C7B00433548 /* RNTNativeErrorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNTNativeErrorTests.swift; sourceTree = "<group>"; };
A17A44BF2BFF650A00433548 /* RNTBanksCollectableDataTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNTBanksCollectableDataTests.swift; sourceTree = "<group>"; };
B7FC3B6D8BEFAD7734A2FDC8 /* Pods-example_0_70_6-ios_sdk_tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example_0_70_6-ios_sdk_tests.debug.xcconfig"; path = "Target Support Files/Pods-example_0_70_6-ios_sdk_tests/Pods-example_0_70_6-ios_sdk_tests.debug.xcconfig"; sourceTree = "<group>"; };
C15C82089BBDB7EBFE153BBA /* Pods-example_0_70_6.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example_0_70_6.release.xcconfig"; path = "Target Support Files/Pods-example_0_70_6/Pods-example_0_70_6.release.xcconfig"; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -89,10 +111,9 @@
children = (
00E356F01AD99517003FC87E /* Supporting Files */,
F004EDB42BF6091A006F3CAA /* example_0_70_6Tests-Bridging-Header.h */,
F004EDB72BF60A4E006F3CAA /* UIColorExtensionTests.swift */,
A17A44A12BF7A57F00433548 /* CodableExtensionsTests.swift */,
A17A44A22BF7A57F00433548 /* ErrorExtensionTests.swift */,
A17A44A02BF7A57F00433548 /* UIImageExtensionTests.swift */,
A17A44AB2BFB825B00433548 /* HelpersTests */,
A17A44A82BFB7D3800433548 /* RNTPrimerTests.swift */,
A17A44AE2BFB844800433548 /* DataModelsTests */,
);
path = example_0_70_6Tests;
sourceTree = "<group>";
Expand Down Expand Up @@ -162,6 +183,42 @@
name = Products;
sourceTree = "<group>";
};
A17A44AB2BFB825B00433548 /* HelpersTests */ = {
isa = PBXGroup;
children = (
F004EDB72BF60A4E006F3CAA /* UIColorExtensionTests.swift */,
A17A44A12BF7A57F00433548 /* CodableExtensionsTests.swift */,
A17A44A22BF7A57F00433548 /* ErrorExtensionTests.swift */,
A17A44A02BF7A57F00433548 /* UIImageExtensionTests.swift */,
A17A44A62BFB7A6200433548 /* PrimerCheckoutPaymentMethodTypeTests.swift */,
);
path = HelpersTests;
sourceTree = "<group>";
};
A17A44AE2BFB844800433548 /* DataModelsTests */ = {
isa = PBXGroup;
children = (
A17A44AC2BFB843F00433548 /* ImplementedRNCallbacksTests.swift */,
A17A44AF2BFB851900433548 /* PrimerBancontactCardRedirectData+ExtensionTests.swift */,
A17A44B12BFB858D00433548 /* PrimerCardData+ExtensionTests.swift */,
A17A44B32BFB865300433548 /* PrimerPhoneNumberData+ExtensionTests.swift */,
A17A44B52BFB86D700433548 /* PrimerRawRetailerData+ExtensionTests.swift */,
A17A44B72BFB874600433548 /* PrimerSettings+ExtensionsTests.swift */,
A17A44B92BFB8AD200433548 /* PrimerThemeRNTests.swift */,
A17A44BB2BFB8C7B00433548 /* RNTNativeErrorTests.swift */,
A17A44C12BFF650F00433548 /* Banks Component */,
);
path = DataModelsTests;
sourceTree = "<group>";
};
A17A44C12BFF650F00433548 /* Banks Component */ = {
isa = PBXGroup;
children = (
A17A44BF2BFF650A00433548 /* RNTBanksCollectableDataTests.swift */,
);
path = "Banks Component";
sourceTree = "<group>";
};
BBD78D7AC51CEA395F1C20DB /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -456,10 +513,21 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A17A44BC2BFB8C7B00433548 /* RNTNativeErrorTests.swift in Sources */,
F004EDB82BF60A4E006F3CAA /* UIColorExtensionTests.swift in Sources */,
A17A44AD2BFB843F00433548 /* ImplementedRNCallbacksTests.swift in Sources */,
A17A44B22BFB858D00433548 /* PrimerCardData+ExtensionTests.swift in Sources */,
A17A44A92BFB7D3800433548 /* RNTPrimerTests.swift in Sources */,
A17A44A32BF7A57F00433548 /* UIImageExtensionTests.swift in Sources */,
A17A44A52BF7A57F00433548 /* ErrorExtensionTests.swift in Sources */,
A17A44C02BFF650A00433548 /* RNTBanksCollectableDataTests.swift in Sources */,
A17A44B02BFB851900433548 /* PrimerBancontactCardRedirectData+ExtensionTests.swift in Sources */,
A17A44A72BFB7A6200433548 /* PrimerCheckoutPaymentMethodTypeTests.swift in Sources */,
A17A44B42BFB865300433548 /* PrimerPhoneNumberData+ExtensionTests.swift in Sources */,
A17A44B82BFB874600433548 /* PrimerSettings+ExtensionsTests.swift in Sources */,
A17A44BA2BFB8AD200433548 /* PrimerThemeRNTests.swift in Sources */,
A17A44A42BF7A57F00433548 /* CodableExtensionsTests.swift in Sources */,
A17A44B62BFB86D700433548 /* PrimerRawRetailerData+ExtensionTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
6 changes: 3 additions & 3 deletions packages/example/ios/example_0_70_6/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ let project = Project(
LaunchArgument(name: "-PrimerDebugEnabled", isEnabled: true),
LaunchArgument(name: "-PrimerAnalyticsDebugEnabled", isEnabled: true)
]
)
)
)
)
)
)
]
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
//
// 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")
let bankIdRN: BankIdRN?

switch bankData {
case .bankId(let bankId):
bankIdRN = BankIdRN(id: bankId)
default:
bankIdRN = nil
}

if let bankIdRN = bankIdRN {
XCTAssertEqual(bankIdRN.validatableDataName, "bankId")
XCTAssertEqual(bankIdRN.id, "bankId123")
} else {
XCTFail("Conversion to BankIdRN failed")
}
}

func testBanksCollectableDataToFilterRN() {
let filterData = BanksCollectableData.bankFilterText(text: "filterText")
let filterRN: FilterRN?

switch filterData {
case .bankFilterText(let text):
filterRN = FilterRN(text: text)
default:
filterRN = nil
}

if let filterRN = filterRN {
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)")
}
}
}
Loading

0 comments on commit 0c9056e

Please sign in to comment.