Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix onDismiss not called when view controller is explicitly dismissed #255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading