Remove Task.sleep from NotificationTests. (#1326)

- Add `weak` to mock variables called `delegate`
- Delete `UserNotificationCenterSpy` and use `UserNotificationCenterMock`
- Remove Task.sleep in favour of mock closures along with expectations/fulfillment.
This commit is contained in:
David Langley
2023-07-14 13:45:42 +01:00
committed by GitHub
parent dfdaee0563
commit bf91e97c88
6 changed files with 60 additions and 122 deletions
@@ -217,7 +217,7 @@ class NotificationCenterMock: NotificationCenterProtocol {
}
}
class NotificationManagerMock: NotificationManagerProtocol {
var delegate: NotificationManagerDelegate?
weak var delegate: NotificationManagerDelegate?
//MARK: - start
@@ -1604,7 +1604,7 @@ class UserIndicatorControllerMock: UserIndicatorControllerProtocol {
}
}
class UserNotificationCenterMock: UserNotificationCenterProtocol {
var delegate: UNUserNotificationCenterDelegate?
weak var delegate: UNUserNotificationCenterDelegate?
//MARK: - add
@@ -17,8 +17,6 @@
import Foundation
import UserNotifications
// Sadly we can't mock this because the delegate needs to be weak
// Use UserNotificationCenterSpy
protocol UserNotificationCenterProtocol: AnyObject {
var delegate: UNUserNotificationCenterDelegate? { get set }
func add(_ request: UNNotificationRequest) async throws