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

Commit

Permalink
Add a unit test verifying that the completion handler is called when …
Browse files Browse the repository at this point in the history
…duration == 0. (#34)

* Add a unit test verifying that the completion handler is called when duration == 0.

* Remove additive setting.
  • Loading branch information
jverkoey committed Nov 7, 2017
1 parent 1793979 commit 81b140a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/unit/MotionAnimatorTests.swift
Expand Up @@ -69,4 +69,27 @@ class MotionAnimatorTests: XCTestCase {
XCTAssertEqual(view.layer.animationKeys()?.count, 1)
}
}

func testCompletionCallbackIsExecutedWithZeroDuration() {
let animator = MotionAnimator()

let timing = MotionTiming(delay: 0,
duration: 0,
curve: .init(type: .bezier, data: (0, 0, 0, 0)),
repetition: .init(type: .none, amount: 0, autoreverses: false))

let window = UIWindow()
window.makeKeyAndVisible()
let view = UIView() // Need to animate a view's layer to get implicit animations.
window.addSubview(view)

XCTAssertEqual(view.layer.delegate as? UIView, view)

let didComplete = expectation(description: "Did complete")
animator.animate(with: timing, to: view.layer, withValues: [0, 1], keyPath: .rotation) {
didComplete.fulfill()
}

waitForExpectations(timeout: 1)
}
}

0 comments on commit 81b140a

Please sign in to comment.