Skip to content

Commit 3fbccb9

Browse files
committed
Adds tests to navigation
1 parent cf5c8ec commit 3fbccb9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,25 @@ final class SimplePaymentsSummaryViewModelTests: XCTestCase {
142142
// Then
143143
XCTAssertTrue(receivedError)
144144
}
145+
146+
func test_when_order_is_updated_navigation_to_payments_method_is_triggered() {
147+
// Given
148+
let mockStores = MockStoresManager(sessionManager: .testingInstance)
149+
let viewModel = SimplePaymentsSummaryViewModel(providedAmount: "1.0", totalWithTaxes: "1.0", taxAmount: "0.0", stores: mockStores)
150+
mockStores.whenReceivingAction(ofType: OrderAction.self) { action in
151+
switch action {
152+
case let .updateSimplePaymentsOrder(_, _, _, _, _, _, _, onCompletion):
153+
onCompletion(.success(Order.fake()))
154+
default:
155+
XCTFail("Unexpected action: \(action)")
156+
}
157+
}
158+
XCTAssertFalse(viewModel.navigateToPaymentMethods)
159+
160+
// When
161+
viewModel.updateOrder()
162+
163+
// Then
164+
XCTAssertTrue(viewModel.navigateToPaymentMethods)
165+
}
145166
}

0 commit comments

Comments
 (0)