Skip to content

Commit 0f8ec6d

Browse files
committed
Mock an action response to prevent the test case sending HTTP request
1 parent 701ba00 commit 0f8ec6d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

WooCommerce/WooCommerceTests/ViewRelated/Orders/Order Details/Addresses/EditOrderAddressFormViewModelTests.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,20 @@ final class EditOrderAddressFormViewModelTests: XCTestCase {
163163

164164
func test_loading_indicator_gets_disabled_after_the_network_operation_completes() {
165165
// Given
166-
let viewModel = EditOrderAddressFormViewModel(order: order(withShippingAddress: sampleAddress()), type: .shipping, storageManager: testingStorage)
166+
let viewModel = EditOrderAddressFormViewModel(
167+
order: order(withShippingAddress: sampleAddress()),
168+
type: .shipping,
169+
storageManager: testingStorage,
170+
stores: testingStores
171+
)
172+
testingStores.whenReceivingAction(ofType: OrderAction.self) { action in
173+
switch action {
174+
case let .updateOrder(_, _, _, onCompletion):
175+
onCompletion(.failure(NSError(domain: "", code: 0)))
176+
default:
177+
XCTFail("Unsupported Action")
178+
}
179+
}
167180

168181
// When
169182
viewModel.onLoadTrigger.send()

0 commit comments

Comments
 (0)