Created
August 6, 2021 09:06
-
-
Save frootloops/96bbf00568966299843399e2b5054756 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AnimatorSpy: Animator { | |
var invokedAnimate = false | |
var invokedAnimateCount = 0 | |
var invokedAnimateParameters: (duration: TimeInterval, Void)? | |
var invokedAnimateParametersList = [(duration: TimeInterval, Void)]() | |
var shouldInvokeAnimateAnimations = false | |
var stubbedAnimateCompletionResult: (Bool, Void)? | |
var stubbedAnimateResult: Bool! = false | |
func animate(duration: TimeInterval, animations: () -> (), completion: (Bool) -> ()) -> Bool { | |
invokedAnimate = true | |
invokedAnimateCount += 1 | |
invokedAnimateParameters = (duration, ()) | |
invokedAnimateParametersList.append((duration, ())) | |
if shouldInvokeAnimateAnimations { | |
animations() | |
} | |
if let result = stubbedAnimateCompletionResult { | |
completion(result.0) | |
} | |
return stubbedAnimateResult | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment