Skip to content

Commit

Permalink
Fix a potential stub issue
Browse files Browse the repository at this point in the history
  • Loading branch information
onevcat committed May 4, 2024
1 parent 26a3005 commit 98b17d7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Tests/KingfisherTests/ImageViewExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,20 @@ class ImageViewExtensionTests: XCTestCase {

@MainActor func testSettingImageKeepingRespectingPlaceholder() {
let exp = expectation(description: #function)
let url = testURLs[0]
stub(url, data: testImageData)


// While current image is nil, set placeholder
imageView.kf.setImage(with: url, placeholder: testImage, options: [.keepCurrentImageWhileLoading]) { result in }
XCTAssertNotNil(imageView.image)
let url = testURLs[0]
imageView.kf.setImage(with: url, placeholder: testImage, options: [.keepCurrentImageWhileLoading]) { result in
exp.fulfill()
}
XCTAssertEqual(testImage, imageView.image)
waitForExpectations(timeout: 3, handler: nil)
}

@MainActor func testMe() {
let exp = expectation(description: #function)
let url = testURLs[0]
stub(url, data: testImageData)

// While current image is not nil, keep it
let anotherImage = KFCrossPlatformImage(data: testImageJEPGData)
Expand All @@ -435,7 +442,6 @@ class ImageViewExtensionTests: XCTestCase {
XCTAssertNotEqual(self.imageView.image, anotherImage)
exp.fulfill()
}
XCTAssertNotNil(imageView.image)
XCTAssertEqual(anotherImage, imageView.image)

waitForExpectations(timeout: 3, handler: nil)
Expand Down

0 comments on commit 98b17d7

Please sign in to comment.