@@ -90,7 +90,11 @@ class AnimatedImageTests: XCTestCase {
90
90
func testAnimatedImageBinding( ) throws {
91
91
let expectation = self . expectation ( description: " AnimatedImage binding control " )
92
92
let binding = Binding < Bool > ( wrappedValue: true )
93
+ var context : AnimatedImage . Context ?
93
94
let imageView = AnimatedImage ( name: " TestLoopCount.gif " , bundle: testImageBundle ( ) , isAnimating: binding)
95
+ . onViewCreate { _, c in
96
+ context = c
97
+ }
94
98
let introspectView = imageView. introspectAnimatedImage { animatedImageView in
95
99
if let animatedImage = animatedImageView. image as? SDAnimatedImage {
96
100
XCTAssertEqual ( animatedImage. animatedImageLoopCount, 1 )
@@ -106,12 +110,8 @@ class AnimatedImageTests: XCTestCase {
106
110
binding. wrappedValue = false
107
111
XCTAssertFalse ( binding. wrappedValue)
108
112
XCTAssertFalse ( imageView. isAnimating)
109
- // TODO: current the Binding value can not been mocked, hardcode here to call `SDAnimatedImageView.stopAnimating`
110
- #if os(iOS) || os(tvOS)
111
- animatedImageView. stopAnimating ( )
112
- #else
113
- animatedImageView. animates = false
114
- #endif
113
+ // Currently ViewInspector's @Binding value update does not trigger `UIViewRepresentable.updateUIView`, mock here
114
+ imageView. updateView ( animatedImageView. superview as! AnimatedImageViewWrapper , context: context!)
115
115
#if os(iOS) || os(tvOS)
116
116
XCTAssertFalse ( animatedImageView. isAnimating)
117
117
#else
0 commit comments