Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 81b140a

Browse files
authored
Add a unit test verifying that the completion handler is called when duration == 0. (#34)
* Add a unit test verifying that the completion handler is called when duration == 0. * Remove additive setting.
1 parent 1793979 commit 81b140a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/unit/MotionAnimatorTests.swift

+23
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,27 @@ class MotionAnimatorTests: XCTestCase {
6969
XCTAssertEqual(view.layer.animationKeys()?.count, 1)
7070
}
7171
}
72+
73+
func testCompletionCallbackIsExecutedWithZeroDuration() {
74+
let animator = MotionAnimator()
75+
76+
let timing = MotionTiming(delay: 0,
77+
duration: 0,
78+
curve: .init(type: .bezier, data: (0, 0, 0, 0)),
79+
repetition: .init(type: .none, amount: 0, autoreverses: false))
80+
81+
let window = UIWindow()
82+
window.makeKeyAndVisible()
83+
let view = UIView() // Need to animate a view's layer to get implicit animations.
84+
window.addSubview(view)
85+
86+
XCTAssertEqual(view.layer.delegate as? UIView, view)
87+
88+
let didComplete = expectation(description: "Did complete")
89+
animator.animate(with: timing, to: view.layer, withValues: [0, 1], keyPath: .rotation) {
90+
didComplete.fulfill()
91+
}
92+
93+
waitForExpectations(timeout: 1)
94+
}
7295
}

0 commit comments

Comments
 (0)