Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bozidarsevo committed Dec 20, 2024
1 parent 9bd13d6 commit 9f74717
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Yosemite/Yosemite/Stores/WooShippingStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,11 @@ public enum WooShippingLabelPurchaseError: Error {
case purchaseMissingLabels
}

public enum WooShippingLoadPackagesError: Error {
public enum WooShippingLoadPackagesError: Error, Equatable {
case loadingInProgress
case loadingFailed(error: Error)

public static func ==(lhs: WooShippingLoadPackagesError, rhs: WooShippingLoadPackagesError) -> Bool {
return lhs.localizedDescription == rhs.localizedDescription
}
}
8 changes: 4 additions & 4 deletions Yosemite/YosemiteTests/Stores/WooShippingStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ final class WooShippingStoreTests: XCTestCase {
let store = WooShippingStore(dispatcher: dispatcher, storageManager: storageManager, network: network, remote: remote)

// When
let result: Result<WooShippingPackagesResponse, Error> = waitFor { promise in
let result: Result<WooShippingPackagesResponse, WooShippingLoadPackagesError> = waitFor { promise in
let action = WooShippingAction.loadPackages(siteID: self.sampleSiteID) { result in
promise(result)
}
Expand Down Expand Up @@ -306,11 +306,11 @@ final class WooShippingStoreTests: XCTestCase {
// Given
let remote = MockWooShippingRemote()
let expectedError = NetworkError.notFound()
remote.whenLoadPackages(siteID: sampleSiteID, thenReturn: .failure(expectedError))
remote.whenLoadPackages(siteID: sampleSiteID, thenReturn: .failure(WooShippingLoadPackagesError.loadingFailed(error: expectedError)))
let store = WooShippingStore(dispatcher: dispatcher, storageManager: storageManager, network: network, remote: remote)

// When
let result: Result<WooShippingPackagesResponse, Error> = waitFor { promise in
let result: Result<WooShippingPackagesResponse, WooShippingLoadPackagesError> = waitFor { promise in
let action = WooShippingAction.loadPackages(siteID: self.sampleSiteID) { result in
promise(result)
}
Expand All @@ -320,7 +320,7 @@ final class WooShippingStoreTests: XCTestCase {
// Then
XCTAssertTrue(result.isFailure)
let error = try XCTUnwrap(result.failure)
XCTAssertEqual(error as? NetworkError, expectedError)
XCTAssertEqual(error, WooShippingLoadPackagesError.loadingFailed(error: expectedError))
}

// MARK: `purchaseShippingLabel`
Expand Down

0 comments on commit 9f74717

Please sign in to comment.