jonreid / ViewControllerPresentationSpy

Unit test presented and dismissed iOS view controllers, including alerts and action sheets
MIT License
149 stars 15 forks source link

MFMailComposeViewController problems dismissing in lower than iOS13 versions #7

Closed sreddy100 closed 3 years ago

sreddy100 commented 3 years ago

I have a method I want to test it works perfectly fine on devices with iOS13 and above. Older versions, however, do not seem to verify the dismiss of an MFMailComposeViewController even if I debug and see it correctly execute the line of code.

My code will do something on the lines of this:

        let dismissVerifier = DismissalVerifier()
        let mailController = MFMailComposeViewController(rootViewController: sut)
        let error = CustomError(title: "Test", description: "test")

        sut.mailComposeController(mailController, didFinishWith: .sent, error: error)

        dismissVerifier.verify(animated: true, dismissedViewController: mailController)

in my mailComposeController(mailController, didFinishWith: .sent, error: error) I will just set mailController to another variable then dismiss it.