Skip to content

Commit f0455fb

Browse files
committed
Add test for card and tap to pay options hiding in CIAB
1 parent fe18ea4 commit f0455fb

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

WooCommerce/WooCommerceTests/ViewRelated/Orders/Payment Methods/PaymentMethodsViewModelTests.swift

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import WooFoundation
66

77
@testable import WooCommerce
88
@testable import Yosemite
9+
@testable import Networking
910

1011
private typealias Dependencies = PaymentMethodsViewModel.Dependencies
1112

@@ -785,6 +786,58 @@ final class PaymentMethodsViewModelTests: XCTestCase {
785786
XCTAssertFalse(viewModel.showTapToPayRow)
786787
}
787788

789+
func test_card_rows_are_not_shown_for_ciab_site() {
790+
// Given
791+
let siteID: Int64 = 1212
792+
let orderID: Int64 = 111
793+
let ciabSite = Site.fake().copy(siteID: siteID, isGarden: true, gardenName: "commerce")
794+
let order = MockOrders()
795+
.makeOrder(status: .pending)
796+
.copy(
797+
siteID: siteID,
798+
orderID: orderID,
799+
datePaid: .some(nil),
800+
total: "100"
801+
)
802+
803+
storage.insertSampleSite(readOnlySite: ciabSite)
804+
storage.insertSampleOrder(readOnlyOrder: order)
805+
806+
let eligibilityStore = OrderCardPresentPaymentEligibilityStore(
807+
dispatcher: Dispatcher(),
808+
storageManager: storage,
809+
network: MockNetwork(),
810+
currentSite: { ciabSite }
811+
)
812+
813+
let configuration = CardPresentPaymentsConfiguration(country: .US)
814+
stores.whenReceivingAction(ofType: OrderCardPresentPaymentEligibilityAction.self) { action in
815+
eligibilityStore.onAction(action)
816+
}
817+
818+
simulate(tapToPayDeviceAvailability: true, on: stores)
819+
820+
// When
821+
let dependencies = Dependencies(
822+
stores: stores,
823+
storage: storage,
824+
cardPresentPaymentsConfiguration: configuration
825+
)
826+
let viewModel = PaymentMethodsViewModel(
827+
siteID: siteID,
828+
orderID: orderID,
829+
total: "5",
830+
formattedTotal: "$5.00",
831+
flow: .simplePayment,
832+
channel: .storeManagement,
833+
dependencies: dependencies
834+
)
835+
836+
// Then
837+
XCTAssertFalse(viewModel.showPayWithCardRow)
838+
XCTAssertFalse(viewModel.showTapToPayRow)
839+
}
840+
788841
func test_paymentLinkRow_is_hidden_if_payment_link_is_not_available() {
789842
// Given
790843
let viewModel = PaymentMethodsViewModel(paymentLink: nil,

0 commit comments

Comments
 (0)