Skip to content

Commit 367c36a

Browse files
committed
Fix failed tests
1 parent d82bb25 commit 367c36a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Modules/Sources/Networking/Mapper/WooShippingOriginAddressMapper.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import Foundation
22

33
struct WooShippingOriginAddressUpdateMapper: Mapper {
4+
/// Site ID associated to the origin addresses that will be parsed.
5+
///
6+
/// We're injecting this field via `JSONDecoder.userInfo` because SiteID is not returned from the remote.
7+
///
8+
let siteID: Int64
9+
410
/// (Attempts) to convert a dictionary into a WooShippingOriginAddressUpdate.
511
///
612
func map(response: Data) throws -> WooShippingOriginAddressUpdate {
713
let decoder = JSONDecoder()
14+
decoder.userInfo = [.siteID: siteID]
815
if hasDataEnvelope(in: response) {
916
return try decoder.decode(WooShippingOriginAddressUpdateMapperEnvelope.self, from: response).data
1017
} else {

Modules/Sources/Networking/Remote/WooShippingRemote.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public final class WooShippingRemote: Remote, WooShippingRemoteProtocol {
431431
path: Path.updateOrigin,
432432
parameters: parameters,
433433
availableAsRESTRequest: true)
434-
let mapper = WooShippingOriginAddressUpdateMapper()
434+
let mapper = WooShippingOriginAddressUpdateMapper(siteID: siteID)
435435
enqueue(request, mapper: mapper, completion: completion)
436436
} catch {
437437
completion(.failure(error))

WooCommerce/WooCommerceTests/ViewRelated/Shipping Label/WooShipping Create Shipping Labels/WooShippingEditAddressViewModelTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ final class WooShippingEditAddressViewModelTests: XCTestCase {
944944
address2: "",
945945
city: "TICONDEROGA",
946946
postcode: "12883-1487")
947-
let stores = MockStoresManager(sessionManager: .testingInstance)
947+
let stores = MockStoresManager(sessionManager: .makeForTesting(defaultSite: .fake().copy(siteID: 123)))
948948
let viewModel = WooShippingEditAddressViewModel(address: originAddress, stores: stores)
949949

950950
// When

0 commit comments

Comments
 (0)