Skip to content

Commit f8ee3f1

Browse files
Test that trying to replace a non-existent product ID does nothing.
1 parent db18a77 commit f8ee3f1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

WooCommerce/WooCommerceTests/ViewRelated/Products/Media/ProductImageUploaderTests.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,29 @@ final class ProductImageUploaderTests: XCTestCase {
168168
isLocalID: false,
169169
originalStatuses: []).productImageStatuses)
170170
}
171+
172+
func test_calling_replaceLocalID_with_nonExistent_localProductID_does_nothing() {
173+
// Given
174+
let imageUploader = ProductImageUploader()
175+
let localProductID: Int64 = 0
176+
let nonExistentProductID: Int64 = 999
177+
let remoteProductID = productID
178+
let originalStatuses: [ProductImageStatus] = [.remote(image: ProductImage.fake()),
179+
.uploading(asset: PHAsset()),
180+
.uploading(asset: PHAsset())]
181+
_ = imageUploader.actionHandler(siteID: siteID,
182+
productID: localProductID,
183+
isLocalID: true,
184+
originalStatuses: originalStatuses)
185+
186+
// When
187+
imageUploader.replaceLocalID(siteID: siteID, localProductID: nonExistentProductID, remoteProductID: remoteProductID)
188+
189+
// Then
190+
// Ensure that trying to replace a non-existent product ID does nothing.
191+
XCTAssertEqual(originalStatuses, imageUploader.actionHandler(siteID: siteID,
192+
productID: localProductID,
193+
isLocalID: true,
194+
originalStatuses: []).productImageStatuses)
195+
}
171196
}

0 commit comments

Comments
 (0)