Skip to content

Commit cb2e10f

Browse files
committed
Update unit tests
1 parent 9c2ae63 commit cb2e10f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Modules/Tests/YosemiteTests/Stores/WooShippingStoreTests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,8 +1083,9 @@ final class WooShippingStoreTests: XCTestCase {
10831083
usedDate: nil,
10841084
expiryDate: nil)
10851085
}()
1086+
let shipments = ["0": [WooShippingShipmentItem.fake()]]
10861087
let expectedResponse = WooShippingConfig.fake().copy(
1087-
shipments: ["0": [WooShippingShipmentItem.fake()]],
1088+
shipments: shipments,
10881089
shippingLabelData: WooShippingLabelData(currentOrderLabels: [expectedShippingLabel])
10891090
)
10901091
remote.whenLoadingConfig(siteID: sampleSiteID, thenReturn: .success(expectedResponse))
@@ -1093,7 +1094,7 @@ final class WooShippingStoreTests: XCTestCase {
10931094
insertOrder(siteID: sampleSiteID, orderID: orderID)
10941095

10951096
// When
1096-
let result: Result<[Yosemite.ShippingLabel], Error> = waitFor { promise in
1097+
let result: Result<ShippingLabelSyncResult, Error> = waitFor { promise in
10971098
let action = WooShippingAction.syncShippingLabels(siteID: self.sampleSiteID, orderID: orderID) { result in
10981099
promise(result)
10991100
}
@@ -1102,6 +1103,9 @@ final class WooShippingStoreTests: XCTestCase {
11021103

11031104
// Then
11041105
XCTAssertTrue(result.isSuccess)
1106+
let syncResult = try XCTUnwrap(result.get())
1107+
XCTAssertEqual(syncResult.labels, [expectedShippingLabel])
1108+
XCTAssertEqual(syncResult.shipments, shipments)
11051109

11061110
let persistedOrder = try XCTUnwrap(viewStorage.loadOrder(siteID: sampleSiteID, orderID: orderID))
11071111
let persistedShippingLabels = try XCTUnwrap(viewStorage.loadAllShippingLabels(siteID: sampleSiteID, orderID: orderID))

WooCommerce/WooCommerceTests/ViewRelated/OrderDetailsViewModelTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ final class OrderDetailsViewModelTests: XCTestCase {
152152

153153
let plugin = insertSystemPlugin(path: SitePlugin.SupportedPluginPath.WooShipping, siteID: order.siteID, isActive: true)
154154
whenFetchingSystemPlugin(path: SitePlugin.SupportedPluginPath.WooShipping, thenReturn: plugin)
155-
whenSyncingShippingLabels(thenReturn: .success([]))
155+
whenSyncingShippingLabels(thenReturn: .success(ShippingLabelSyncResult.none))
156156

157157
let featureFlagService = MockFeatureFlagService(revampedShippingLabelCreation: true)
158158
let viewModel = OrderDetailsViewModel(order: order,
@@ -789,7 +789,7 @@ private extension OrderDetailsViewModelTests {
789789
}
790790
}
791791

792-
func whenSyncingShippingLabels(thenReturn result: Result<[ShippingLabel], Error>) {
792+
func whenSyncingShippingLabels(thenReturn result: Result<ShippingLabelSyncResult, Error>) {
793793
storesManager.whenReceivingAction(ofType: WooShippingAction.self) { action in
794794
switch action {
795795
case let .syncShippingLabels(_, _, completion):

0 commit comments

Comments
 (0)