Skip to content

Commit

Permalink
Add unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Solovev committed Dec 5, 2023
1 parent 05a4c95 commit 8051fbf
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
4 changes: 4 additions & 0 deletions OmiseSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
75F2A0BB2A1A60630038FA54 /* AtomeFormViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0B52A1A5F020038FA54 /* AtomeFormViewContext.swift */; };
75F2A0C12A1A84900038FA54 /* UIColor+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */; };
75F2A0C22A1A87AE0038FA54 /* UIColor+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */; };
75F8C0B72B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */; };
8A01E48D21059EFF00D73FE6 /* PaymentInformation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A01E48C21059EFF00D73FE6 /* PaymentInformation.swift */; };
8A01F78B20D90EC5003FC11E /* Client+ObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A01F78A20D90EC5003FC11E /* Client+ObjC.swift */; };
8A01F78E20D91091003FC11E /* OMSTokenRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A01F78D20D91091003FC11E /* OMSTokenRequest.swift */; };
Expand Down Expand Up @@ -316,6 +317,7 @@
75F2A0B32A1A5EAD0038FA54 /* AtomeFormViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewModelProtocol.swift; sourceTree = "<group>"; };
75F2A0B52A1A5F020038FA54 /* AtomeFormViewContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomeFormViewContext.swift; sourceTree = "<group>"; };
75F2A0C02A1A84900038FA54 /* UIColor+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Helpers.swift"; sourceTree = "<group>"; };
75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentChooserViewControllerTests.swift; sourceTree = "<group>"; };
8A00FEC21F1DE88600246078 /* README.md */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; tabWidth = 2; };
8A01E48C21059EFF00D73FE6 /* PaymentInformation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentInformation.swift; sourceTree = "<group>"; };
8A01F78A20D90EC5003FC11E /* Client+ObjC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Client+ObjC.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -882,6 +884,7 @@
isa = PBXGroup;
children = (
F615CBF7261565D600E1A2D9 /* CardExpiryDatePickerTests.swift */,
75F8C0B62B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -1349,6 +1352,7 @@
7509D4E72A1C8E3D0050AB38 /* AtomeFormViewModelTests.swift in Sources */,
7509D4E22A1C876B0050AB38 /* AtomeFormViewContextMockup.swift in Sources */,
8A3C10562159F7FC00BEFD8A /* InvalidCardAPIErrorParsingTestCase.swift in Sources */,
75F8C0B72B1F78E300AE78D9 /* PaymentChooserViewControllerTests.swift in Sources */,
758244092ACE988700781B3B /* PaymentInformationTestCase.swift in Sources */,
8A37E43620B584D300E2DA18 /* ModelTestCase.swift in Sources */,
);
Expand Down
90 changes: 90 additions & 0 deletions OmiseSDKTests/Views/PaymentChooserViewControllerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// PaymentChooserViewControllerTests.swift
// OmiseSDKTests
//
// Created by Andrei Solovev on 5/12/23.
// Copyright © 2023 Omise. All rights reserved.
//

import XCTest
@testable import OmiseSDK

class PaymentChooserViewControllerTests: XCTestCase {
let allSourceTypes: [OMSSourceTypeValue] = [
.internetBankingBAY,
.internetBankingBBL,
.mobileBankingSCB,
.mobileBankingOCBCPAO,
.mobileBankingOCBC,
.mobileBankingBAY,
.mobileBankingBBL,
.mobileBankingKTB,
.alipay,
.alipayCN,
.alipayHK,
.billPaymentTescoLotus,
.barcodeAlipay,
.dana,
.gcash,
.installmentBAY,
.installmentFirstChoice,
.installmentBBL,
.installmentMBB,
.installmentKTC,
.installmentKBank,
.installmentSCB,
.installmentCiti,
.installmentTTB,
.installmentUOB,
.kakaoPay,
.eContext,
.promptPay,
.payNow,
.touchNGo,
.touchNGoAlipayPlus,
.trueMoney,
.trueMoneyJumpApp,
.pointsCiti,
.fpx,
.mobileBankingKBank,
.rabbitLinepay,
.grabPay,
.grabPayRms,
.boost,
.shopeePay,
.shopeePayJumpApp,
.maybankQRPay,
.duitNowQR,
.duitNowOBW,
.atome,
.payPay
]

func testTruemoveFiltering() {
let trueMoneyWalletOnly = allSourceTypes.filter { $0 != .trueMoneyJumpApp }
let trueMoneyJumpAppOnly = allSourceTypes.filter { $0 != .trueMoney }
let trueMoneyAndJumpApp = allSourceTypes
let noTrueMoneyAndJumpApp = allSourceTypes.filter {
($0 != .trueMoney) && ($0 != .trueMoneyJumpApp)
}

let vc = PaymentChooserViewController()
vc.loadView()

vc.allowedPaymentMethods = trueMoneyWalletOnly
XCTAssertTrue(vc.showingValues.contains(.truemoney))
XCTAssertFalse(vc.showingValues.contains(.truemoneyJumpApp))

vc.allowedPaymentMethods = trueMoneyJumpAppOnly
XCTAssertTrue(vc.showingValues.contains(.truemoneyJumpApp))
XCTAssertFalse(vc.showingValues.contains(.truemoney))

vc.allowedPaymentMethods = trueMoneyAndJumpApp
XCTAssertTrue(vc.showingValues.contains(.truemoneyJumpApp))
XCTAssertFalse(vc.showingValues.contains(.truemoney))

vc.allowedPaymentMethods = noTrueMoneyAndJumpApp
XCTAssertFalse(vc.showingValues.contains(.truemoneyJumpApp))
XCTAssertFalse(vc.showingValues.contains(.truemoney))
}
}

0 comments on commit 8051fbf

Please sign in to comment.