|
| 1 | +@_spi(package) @testable import Animator |
| 2 | +@_spi(package) import AtomicTransition |
| 3 | +import CustomDump |
| 4 | +import SwiftUI |
| 5 | +import XCTest |
| 6 | + |
| 7 | +final class ScaleTests: XCTestCase { |
| 8 | + let animatorUsed = UnimplementedAnimator() |
| 9 | + let uiViewUsed = UIView() |
| 10 | + lazy var viewUsed = AnimatorTransientView(uiViewUsed) |
| 11 | + let properties = AnimatorTransientViewProperties(alpha: 1, transform: .identity) |
| 12 | + lazy var contextUsed = MockedContext(containerView: UIView()) |
| 13 | + |
| 14 | + func testInsertion() { |
| 15 | + AtomicTransition.scale(0.5).prepare(animatorUsed, or: viewUsed, for: .insertion, in: contextUsed) |
| 16 | + |
| 17 | + var initial = properties |
| 18 | + initial.transform = .identity.scaledBy(x: 0.5, y: 0.5) |
| 19 | + XCTAssertNoDifference(viewUsed.initial, initial) |
| 20 | + |
| 21 | + var animation = properties |
| 22 | + animation.transform = .identity.rotated(by: 0) |
| 23 | + XCTAssertNoDifference(viewUsed.animation, animation) |
| 24 | + |
| 25 | + let completion = properties |
| 26 | + XCTAssertNoDifference(viewUsed.completion, completion) |
| 27 | + } |
| 28 | + |
| 29 | + func testRemoval() { |
| 30 | + AtomicTransition.scale(0.5).prepare(animatorUsed, or: viewUsed, for: .removal, in: contextUsed) |
| 31 | + |
| 32 | + let initial = properties |
| 33 | + XCTAssertNoDifference(viewUsed.initial, initial) |
| 34 | + |
| 35 | + var animation = properties |
| 36 | + animation.transform = .identity.scaledBy(x: 0.5, y: 0.5) |
| 37 | + XCTAssertNoDifference(viewUsed.animation, animation) |
| 38 | + |
| 39 | + var completion = properties |
| 40 | + completion.transform = .identity.rotated(by: 0) |
| 41 | + XCTAssertNoDifference(viewUsed.completion, completion) |
| 42 | + } |
| 43 | + |
| 44 | + // TODO: assert for (x, y | x | y) conveniences equality when this is done: |
| 45 | + // https://github.com/davdroman/swiftui-navigation-transitions/discussions/6 |
| 46 | + // func testConveniences() {} |
| 47 | +} |
0 commit comments