Skip to content

Commit

Permalink
Update the test case about onViewCreate/onViewUpdate/onViewDestroy
Browse files Browse the repository at this point in the history
  • Loading branch information
dreampiggy committed Jan 28, 2020
1 parent b94f3a5 commit 3ccd996
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Tests/AnimatedImageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class AnimatedImageTests: XCTestCase {
func testAnimatedImageModifier() throws {
let expectation = self.expectation(description: "WebImage modifier")
let imageUrl = URL(string: "https://assets.sbnation.com/assets/2512203/dogflops.gif")
AnimatedImage.onViewDestroy { view, coordinator in
XCTAssert(view.isKind(of: SDAnimatedImageView.self))
XCTAssertEqual(coordinator.userInfo?["foo"] as? String, "bar")
}
let imageView = AnimatedImage(url: imageUrl, options: [.progressiveLoad], context: [.imageScaleFactor: 1])
let introspectView = imageView
.onSuccess { _, _ in
Expand All @@ -137,6 +141,14 @@ class AnimatedImageTests: XCTestCase {
}
.onProgress { _, _ in

}
.onViewCreate { view, context in
XCTAssert(view.isKind(of: SDAnimatedImageView.self))
context.coordinator.userInfo = ["foo" : "bar"]
}
.onViewUpdate { view, context in
XCTAssert(view.isKind(of: SDAnimatedImageView.self))
XCTAssertEqual(context.coordinator.userInfo?["foo"] as? String, "bar")
}
.placeholder(WebImage.emptyImage)
.indicator(SDWebImageActivityIndicator.medium)
Expand All @@ -157,6 +169,7 @@ class AnimatedImageTests: XCTestCase {
_ = try introspectView.inspect(AnimatedImage.self)
ViewHosting.host(view: introspectView)
self.waitForExpectations(timeout: 5, handler: nil)
AnimatedImage.onViewDestroy()
}

// MARK: Helper
Expand Down

0 comments on commit 3ccd996

Please sign in to comment.