Skip to content

Commit 2da8a4e

Browse files
author
Sharma Elanthiriayan
committed
SimplePaymentsSummaryViewModelTests fix test_provided_amount_gets_properly_formatted test
- Mock `getSimplePaymentsTaxesToggleState` to ensure that taxes toggle doesn't get turned on.
1 parent 7b6c7c4 commit 2da8a4e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

WooCommerce/WooCommerceTests/ViewRelated/Orders/Simple Payments/SimplePaymentsSummaryViewModelTests.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,24 @@ final class SimplePaymentsSummaryViewModelTests: XCTestCase {
4040

4141
func test_provided_amount_gets_properly_formatted() {
4242
// Given
43+
let mockStores = MockStoresManager(sessionManager: .testingInstance)
44+
mockStores.whenReceivingAction(ofType: AppSettingsAction.self) { action in
45+
switch action {
46+
case let .getSimplePaymentsTaxesToggleState(_, onCompletion):
47+
onCompletion(.success(false)) // Keep the taxes toggle turned off
48+
case .setSimplePaymentsTaxesToggleState:
49+
break // No op
50+
default:
51+
XCTFail("Unexpected action: \(action)")
52+
}
53+
}
54+
4355
let currencyFormatter = CurrencyFormatter(currencySettings: CurrencySettings()) // Default is US.
44-
let viewModel = SimplePaymentsSummaryViewModel(providedAmount: "100", totalWithTaxes: "104.30", taxAmount: "$4.3", currencyFormatter: currencyFormatter)
56+
let viewModel = SimplePaymentsSummaryViewModel(providedAmount: "100",
57+
totalWithTaxes: "104.30",
58+
taxAmount: "$4.3",
59+
currencyFormatter: currencyFormatter,
60+
stores: mockStores)
4561

4662
// When & Then
4763
XCTAssertEqual(viewModel.providedAmount, "$100.00")
@@ -235,6 +251,7 @@ final class SimplePaymentsSummaryViewModelTests: XCTestCase {
235251
let viewModel = SimplePaymentsSummaryViewModel(providedAmount: "1.0",
236252
totalWithTaxes: "1.0",
237253
taxAmount: "0.0",
254+
stores: mockStores,
238255
analytics: WooAnalytics(analyticsProvider: mockAnalytics))
239256

240257
// When

0 commit comments

Comments
 (0)