Skip to content

Commit

Permalink
Add test for explicitly dismissing view controller
Browse files Browse the repository at this point in the history
  • Loading branch information
acosmicflamingo committed Dec 19, 2024
1 parent 29ccee2 commit e323d3a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Examples/CaseStudiesTests/PresentationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ final class PresentationTests: XCTestCase {
await assertEventuallyEqual(vc.isPresenting, false)
}

@MainActor
func testPresents_Dismissal() async throws {
let vc = BasicViewController()
try await setUp(controller: vc)

await assertEventuallyNil(vc.presentedViewController)

withUITransaction(\.uiKit.disablesAnimations, true) {
vc.model.isPresented = true
}
await assertEventuallyNotNil(vc.presentedViewController)
await assertEventuallyEqual(vc.isPresenting, true)

withUITransaction(\.uiKit.disablesAnimations, true) {
vc.presentedViewController?.dismiss(animated: false)
}
await assertEventuallyNil(vc.presentedViewController)
await assertEventuallyEqual(vc.model.isPresented, false)
await assertEventuallyEqual(vc.isPresenting, false)
}

@MainActor
func testPresents_TraitDismissal() async throws {
let vc = BasicViewController()
Expand All @@ -53,12 +74,14 @@ final class PresentationTests: XCTestCase {
vc.model.isPresented = true
}
await assertEventuallyNotNil(vc.presentedViewController)
await assertEventuallyEqual(vc.isPresenting, true)

withUITransaction(\.uiKit.disablesAnimations, true) {
vc.presentedViewController?.traitCollection.dismiss()
}
await assertEventuallyNil(vc.presentedViewController)
await assertEventuallyEqual(vc.model.isPresented, false)
await assertEventuallyEqual(vc.isPresenting, false)
}

@MainActor
Expand Down

0 comments on commit e323d3a

Please sign in to comment.