From 5f144714fae9c524a17827be74303f4e594ad64a Mon Sep 17 00:00:00 2001 From: Miiha Date: Thu, 7 Sep 2023 09:12:24 +0000 Subject: [PATCH] Run swift-format --- Package.swift | 2 +- .../Interface.swift | 71 ++++---- .../ComposableUserNotifications/LiveKey.swift | 108 ++++++------- .../ComposableUserNotifications/Model.swift | 152 +++++++++--------- .../ComposableUserNotifications/TestKey.swift | 136 ++++++++-------- .../ComposableUserNotificationsTests.swift | 19 +-- .../XCTestManifests.swift | 6 +- 7 files changed, 255 insertions(+), 239 deletions(-) diff --git a/Package.swift b/Package.swift index b109024..64de950 100644 --- a/Package.swift +++ b/Package.swift @@ -18,7 +18,7 @@ let package = Package( ) ], dependencies: [ - .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "0.6.0"), + .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "0.6.0") ], targets: [ .target( diff --git a/Sources/ComposableUserNotifications/Interface.swift b/Sources/ComposableUserNotifications/Interface.swift index 49b5d24..83ba624 100644 --- a/Sources/ComposableUserNotifications/Interface.swift +++ b/Sources/ComposableUserNotifications/Interface.swift @@ -23,57 +23,70 @@ public struct UserNotificationClient { case openSettingsForNotification(_ notification: Notification?) } - public var add: @Sendable (UNNotificationRequest) async throws -> Void = - unimplemented("\(Self.self).add") + public var add: @Sendable (UNNotificationRequest) async throws -> Void = + unimplemented("\(Self.self).add") -#if !os(tvOS) - public var deliveredNotifications: @Sendable () async -> [Notification] = unimplemented("\(Self.self).deliveredNotifications") -#endif + #if !os(tvOS) + public var deliveredNotifications: @Sendable () async -> [Notification] = unimplemented( + "\(Self.self).deliveredNotifications") + #endif -#if !os(tvOS) - public var notificationCategories: () async -> Set = unimplemented("\(Self.self).deliveredNotifications") -#endif + #if !os(tvOS) + public var notificationCategories: () async -> Set = unimplemented( + "\(Self.self).deliveredNotifications") + #endif - public var notificationSettings: () async -> Notification.Settings = unimplemented("\(Self.self).notificationSettings") + public var notificationSettings: () async -> Notification.Settings = unimplemented( + "\(Self.self).notificationSettings") - public var pendingNotificationRequests: () async -> [Notification.Request] = unimplemented("\(Self.self).pendingNotificationRequests") + public var pendingNotificationRequests: () async -> [Notification.Request] = unimplemented( + "\(Self.self).pendingNotificationRequests") -#if !os(tvOS) - public var removeAllDeliveredNotifications: () async -> Void = unimplemented("\(Self.self).removeAllDeliveredNotifications") -#endif + #if !os(tvOS) + public var removeAllDeliveredNotifications: () async -> Void = unimplemented( + "\(Self.self).removeAllDeliveredNotifications") + #endif - public var removeAllPendingNotificationRequests: () async -> Void = unimplemented("\(Self.self).removeAllPendingNotificationRequests") + public var removeAllPendingNotificationRequests: () async -> Void = unimplemented( + "\(Self.self).removeAllPendingNotificationRequests") -#if !os(tvOS) - public var removeDeliveredNotificationsWithIdentifiers: ([String]) async -> Void = unimplemented("\(Self.self).removeDeliveredNotificationsWithIdentifiers") -#endif + #if !os(tvOS) + public var removeDeliveredNotificationsWithIdentifiers: ([String]) async -> Void = + unimplemented("\(Self.self).removeDeliveredNotificationsWithIdentifiers") + #endif - public var removePendingNotificationRequestsWithIdentifiers: ([String]) async -> Void = unimplemented("\(Self.self).removePendingNotificationRequestsWithIdentifiers") + public var removePendingNotificationRequestsWithIdentifiers: ([String]) async -> Void = + unimplemented("\(Self.self).removePendingNotificationRequestsWithIdentifiers") public var requestAuthorization: (UNAuthorizationOptions) async throws -> Bool = - unimplemented("\(Self.self).requestAuthorization") + unimplemented("\(Self.self).requestAuthorization") -#if !os(tvOS) - public var setNotificationCategories: (Set) async -> Void = unimplemented("\(Self.self).setNotificationCategories") -#endif + #if !os(tvOS) + public var setNotificationCategories: (Set) async -> Void = + unimplemented("\(Self.self).setNotificationCategories") + #endif - public var supportsContentExtensions: () -> Bool = unimplemented("\(Self.self).supportsContentExtensions") + public var supportsContentExtensions: () -> Bool = unimplemented( + "\(Self.self).supportsContentExtensions") /// This Effect represents calls to the `UNUserNotificationCenterDelegate`. /// Handling the completion handlers of the `UNUserNotificationCenterDelegate`s methods /// by multiple observers might lead to unexpected behaviour. - public var delegate: @Sendable () -> AsyncStream = unimplemented("\(Self.self).delegate", placeholder: .finished) + public var delegate: @Sendable () -> AsyncStream = unimplemented( + "\(Self.self).delegate", placeholder: .finished) } extension UserNotificationClient.DelegateAction: Equatable { - public static func == (lhs: UserNotificationClient.DelegateAction, rhs: UserNotificationClient.DelegateAction) -> Bool { + public static func == ( + lhs: UserNotificationClient.DelegateAction, rhs: UserNotificationClient.DelegateAction + ) -> Bool { switch (lhs, rhs) { case let (.willPresentNotification(lhs, _), .willPresentNotification(rhs, _)): return lhs == rhs -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - case let (.didReceiveResponse(lhs, _), .didReceiveResponse(rhs, _)): - return lhs == rhs -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + case let (.didReceiveResponse(lhs, _), .didReceiveResponse(rhs, _)): + return lhs == rhs + #endif case let (.openSettingsForNotification(lhs), .openSettingsForNotification(rhs)): return lhs == rhs default: diff --git a/Sources/ComposableUserNotifications/LiveKey.swift b/Sources/ComposableUserNotifications/LiveKey.swift index da4e313..505f2a8 100644 --- a/Sources/ComposableUserNotifications/LiveKey.swift +++ b/Sources/ComposableUserNotifications/LiveKey.swift @@ -1,5 +1,5 @@ -import Foundation import Dependencies +import Foundation import UserNotifications extension UserNotificationClient: DependencyKey { @@ -9,44 +9,44 @@ extension UserNotificationClient: DependencyKey { var client = UserNotificationClient() client.add = { try await UNUserNotificationCenter.current().add($0) } -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - client.deliveredNotifications = { - let notifications = await center.deliveredNotifications() - return notifications.map(Notification.init(rawValue:)) - } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + client.deliveredNotifications = { + let notifications = await center.deliveredNotifications() + return notifications.map(Notification.init(rawValue:)) + } + #endif client.notificationSettings = { let settings = await center.notificationSettings() return Notification.Settings(rawValue: settings) } -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - client.notificationCategories = { - await center.notificationCategories() - } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + client.notificationCategories = { + await center.notificationCategories() + } + #endif client.pendingNotificationRequests = { let requests = await center.pendingNotificationRequests() return requests.map(Notification.Request.init(rawValue:)) } -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - client.removeAllDeliveredNotifications = { - center.removeAllDeliveredNotifications() - } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + client.removeAllDeliveredNotifications = { + center.removeAllDeliveredNotifications() + } + #endif client.removeAllPendingNotificationRequests = { center.removeAllPendingNotificationRequests() } -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - client.removeDeliveredNotificationsWithIdentifiers = { - center.removeDeliveredNotifications(withIdentifiers: $0) - } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + client.removeDeliveredNotificationsWithIdentifiers = { + center.removeDeliveredNotifications(withIdentifiers: $0) + } + #endif client.removePendingNotificationRequestsWithIdentifiers = { center.removePendingNotificationRequests(withIdentifiers: $0) @@ -56,11 +56,11 @@ extension UserNotificationClient: DependencyKey { try await center.requestAuthorization(options: $0) } -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - client.setNotificationCategories = { - center.setNotificationCategories($0) - } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + client.setNotificationCategories = { + center.setNotificationCategories($0) + } + #endif client.supportsContentExtensions = { center.supportsContentExtensions @@ -80,8 +80,8 @@ extension UserNotificationClient: DependencyKey { } } -private extension UserNotificationClient { - class Delegate: NSObject, UNUserNotificationCenterDelegate { +extension UserNotificationClient { + fileprivate class Delegate: NSObject, UNUserNotificationCenterDelegate { let continuation: AsyncStream.Continuation init(continuation: AsyncStream.Continuation) { @@ -92,7 +92,7 @@ private extension UserNotificationClient { _ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: - @escaping (UNNotificationPresentationOptions) -> Void + @escaping (UNNotificationPresentationOptions) -> Void ) { self.continuation.yield( .willPresentNotification( @@ -102,29 +102,29 @@ private extension UserNotificationClient { ) } -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - func userNotificationCenter( - _ center: UNUserNotificationCenter, - didReceive response: UNNotificationResponse, - withCompletionHandler completionHandler: @escaping () -> Void - ) { - let wrappedResponse = Notification.Response(rawValue: response) - self.continuation.yield( - .didReceiveResponse(wrappedResponse) { completionHandler() } - ) - } -#endif - -#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) - func userNotificationCenter( - _ center: UNUserNotificationCenter, - openSettingsFor notification: UNNotification? - ) { - let mappedNotification = notification.map(Notification.init) - self.continuation.yield( - .openSettingsForNotification(mappedNotification) - ) - } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + func userNotificationCenter( + _ center: UNUserNotificationCenter, + didReceive response: UNNotificationResponse, + withCompletionHandler completionHandler: @escaping () -> Void + ) { + let wrappedResponse = Notification.Response(rawValue: response) + self.continuation.yield( + .didReceiveResponse(wrappedResponse) { completionHandler() } + ) + } + #endif + + #if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) + func userNotificationCenter( + _ center: UNUserNotificationCenter, + openSettingsFor notification: UNNotification? + ) { + let mappedNotification = notification.map(Notification.init) + self.continuation.yield( + .openSettingsForNotification(mappedNotification) + ) + } + #endif } } diff --git a/Sources/ComposableUserNotifications/Model.swift b/Sources/ComposableUserNotifications/Model.swift index 5fe2365..295e527 100644 --- a/Sources/ComposableUserNotifications/Model.swift +++ b/Sources/ComposableUserNotifications/Model.swift @@ -1,5 +1,5 @@ -import UserNotifications import CoreLocation +import UserNotifications import XCTestDynamicOverlay public struct Notification: Equatable { @@ -49,10 +49,10 @@ extension Notification { return .calendar(Trigger.Calendar(rawValue: trigger)) case let trigger as UNTimeIntervalNotificationTrigger: return .timeInterval(Trigger.TimeInterval(rawValue: trigger)) -#if (os(iOS) || os(watchOS)) && !targetEnvironment(macCatalyst) - case let trigger as UNLocationNotificationTrigger: - return .location(Trigger.Location(rawValue: trigger)) -#endif + #if (os(iOS) || os(watchOS)) && !targetEnvironment(macCatalyst) + case let trigger as UNLocationNotificationTrigger: + return .location(Trigger.Location(rawValue: trigger)) + #endif default: return nil } @@ -96,10 +96,10 @@ extension Notification { return lhs == rhs case let (.calendar(lhs), .calendar(rhs)): return lhs == rhs -#if os(iOS) || os(watchOS) - case let (.location(lhs), .location(rhs)): - return lhs == rhs -#endif + #if os(iOS) || os(watchOS) + case let (.location(lhs), .location(rhs)): + return lhs == rhs + #endif default: return false } @@ -116,10 +116,10 @@ extension Notification.Trigger { return value.repeats case let .calendar(value): return value.repeats -#if os(iOS) || os(watchOS) - case let .location(value): - return value.repeats -#endif + #if os(iOS) || os(watchOS) + case let .location(value): + return value.repeats + #endif } } @@ -308,13 +308,14 @@ extension Notification.Response { public init( actionIdentifier: String, notification: Notification, - userText: String) { - self.rawValue = nil + userText: String + ) { + self.rawValue = nil - self.actionIdentifier = actionIdentifier - self.notification = notification - self.userText = userText - } + self.actionIdentifier = actionIdentifier + self.notification = notification + self.userText = userText + } } } @@ -330,21 +331,20 @@ extension Notification { @available(tvOS, unavailable) @available(watchOS, unavailable) public var alertStyle: UNAlertStyle { -#if !os(tvOS) && !os(watchOS) - _alertStyle() -#else - fatalError() -#endif + #if !os(tvOS) && !os(watchOS) + _alertStyle() + #else + fatalError() + #endif } -#if !os(tvOS) && !os(watchOS) - @_spi(Internal) - public var _alertStyle: () -> UNAlertStyle = unimplemented("alertStyle") -#endif - + #if !os(tvOS) && !os(watchOS) + @_spi(Internal) + public var _alertStyle: () -> UNAlertStyle = unimplemented("alertStyle") + #endif @available(macOS, unavailable) @available(tvOS, unavailable) - public var announcementSetting: UNNotificationSetting {_announcementSetting() } + public var announcementSetting: UNNotificationSetting { _announcementSetting() } @_spi(Internal) public var _announcementSetting: () -> UNNotificationSetting = unimplemented( "announcementSetting" @@ -396,18 +396,18 @@ extension Notification { @available(tvOS, unavailable) @available(watchOS, unavailable) public var showPreviewsSetting: UNShowPreviewsSetting { -#if !os(tvOS) && !os(watchOS) - _showPreviewsSetting() -#else - fatalError() -#endif + #if !os(tvOS) && !os(watchOS) + _showPreviewsSetting() + #else + fatalError() + #endif } -#if !os(tvOS) && !os(watchOS) - @_spi(Internal) - public var _showPreviewsSetting: () -> UNShowPreviewsSetting = unimplemented( - "showPreviewsSetting" - ) -#endif + #if !os(tvOS) && !os(watchOS) + @_spi(Internal) + public var _showPreviewsSetting: () -> UNShowPreviewsSetting = unimplemented( + "showPreviewsSetting" + ) + #endif @available(tvOS, unavailable) public var soundSetting: UNNotificationSetting { _soundSetting() } @@ -417,50 +417,50 @@ extension Notification { public init(rawValue: UNNotificationSettings) { self.rawValue = { rawValue } -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - self._alertSetting = { rawValue.alertSetting } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + self._alertSetting = { rawValue.alertSetting } + #endif -#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) - self._alertStyle = { rawValue.alertStyle } -#endif + #if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) + self._alertStyle = { rawValue.alertStyle } + #endif -#if os(iOS) || os(watchOS) || targetEnvironment(macCatalyst) - self._announcementSetting = { rawValue.announcementSetting } -#endif + #if os(iOS) || os(watchOS) || targetEnvironment(macCatalyst) + self._announcementSetting = { rawValue.announcementSetting } + #endif self.authorizationStatus = { rawValue.authorizationStatus } -#if os(iOS) || os(macOS) || os(tvOS) || targetEnvironment(macCatalyst) - self._badgeSetting = { rawValue.badgeSetting } -#endif + #if os(iOS) || os(macOS) || os(tvOS) || targetEnvironment(macCatalyst) + self._badgeSetting = { rawValue.badgeSetting } + #endif -#if os(iOS) || targetEnvironment(macCatalyst) - self._carPlaySetting = { rawValue.carPlaySetting } -#endif + #if os(iOS) || targetEnvironment(macCatalyst) + self._carPlaySetting = { rawValue.carPlaySetting } + #endif -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - self._criticalAlertSetting = { rawValue.criticalAlertSetting } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + self._criticalAlertSetting = { rawValue.criticalAlertSetting } + #endif -#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) - self._lockScreenSetting = { rawValue.lockScreenSetting } -#endif + #if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) + self._lockScreenSetting = { rawValue.lockScreenSetting } + #endif -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - self._notificationCenterSetting = { rawValue.notificationCenterSetting } - self._providesAppNotificationSettings = { - rawValue.providesAppNotificationSettings - } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + self._notificationCenterSetting = { rawValue.notificationCenterSetting } + self._providesAppNotificationSettings = { + rawValue.providesAppNotificationSettings + } + #endif -#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) - self._showPreviewsSetting = { rawValue.showPreviewsSetting } -#endif + #if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) + self._showPreviewsSetting = { rawValue.showPreviewsSetting } + #endif -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - self._soundSetting = { rawValue.soundSetting } -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + self._soundSetting = { rawValue.soundSetting } + #endif } public static func == ( @@ -499,8 +499,8 @@ public struct Region: Hashable { public static func == (lhs: Self, rhs: Self) -> Bool { lhs.identifier == rhs.identifier - && lhs.notifyOnEntry == rhs.notifyOnEntry - && lhs.notifyOnExit == rhs.notifyOnExit + && lhs.notifyOnEntry == rhs.notifyOnEntry + && lhs.notifyOnExit == rhs.notifyOnExit } public func hash(into hasher: inout Hasher) { diff --git a/Sources/ComposableUserNotifications/TestKey.swift b/Sources/ComposableUserNotifications/TestKey.swift index 5e52c0e..9d20962 100644 --- a/Sources/ComposableUserNotifications/TestKey.swift +++ b/Sources/ComposableUserNotifications/TestKey.swift @@ -1,5 +1,5 @@ -import Foundation import Dependencies +import Foundation import UserNotifications import XCTestDynamicOverlay @@ -13,73 +13,75 @@ extension DependencyValues { extension UserNotificationClient: TestDependencyKey { public static let previewValue = Self.noop -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - public static let testValue = Self( - add: unimplemented("\(Self.self).add"), - deliveredNotifications: unimplemented("\(Self.self).deliveredNotifications"), - notificationCategories: unimplemented("\(Self.self).notificationCategories", placeholder: []), - notificationSettings: unimplemented("\(Self.self).notificationSettings"), - pendingNotificationRequests: unimplemented("\(Self.self).pendingNotificationRequests"), - removeAllDeliveredNotifications: unimplemented("\(Self.self).removeAllDeliveredNotifications"), - removeAllPendingNotificationRequests: unimplemented( - "\(Self.self).removeAllPendingNotificationRequests" - ), - removeDeliveredNotificationsWithIdentifiers: unimplemented( - "\(Self.self).removeDeliveredNotificationsWithIdentifiers" - ), - removePendingNotificationRequestsWithIdentifiers: unimplemented( - "\(Self.self).removePendingNotificationRequestsWithIdentifiers" - ), - requestAuthorization: unimplemented("\(Self.self).requestAuthorization", placeholder: false), - setNotificationCategories: unimplemented("\(Self.self).setNotificationCategories"), - supportsContentExtensions: unimplemented( - "\(Self.self).supportsContentExtensions", placeholder: false - ), - delegate: unimplemented("\(Self.self).delegate", placeholder: .finished) - ) -#else // tvOS - public static let testValue = Self( - add: unimplemented("\(Self.self).add"), - pendingNotificationRequests: unimplemented("\(Self.self).pendingNotificationRequests"), - removeAllPendingNotificationRequests: unimplemented( - "\(Self.self).removeAllPendingNotificationRequests" - ), - removePendingNotificationRequestsWithIdentifiers: unimplemented("\(Self.self).removePendingNotificationRequestsWithIdentifiers"), - requestAuthorization: unimplemented("\(Self.self).requestAuthorization", placeholder: false), - supportsContentExtensions: unimplemented( - "\(Self.self).supportsContentExtensions", placeholder: false - ), - delegate: unimplemented("\(Self.self).delegate", placeholder: .finished) - ) -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + public static let testValue = Self( + add: unimplemented("\(Self.self).add"), + deliveredNotifications: unimplemented("\(Self.self).deliveredNotifications"), + notificationCategories: unimplemented("\(Self.self).notificationCategories", placeholder: []), + notificationSettings: unimplemented("\(Self.self).notificationSettings"), + pendingNotificationRequests: unimplemented("\(Self.self).pendingNotificationRequests"), + removeAllDeliveredNotifications: unimplemented( + "\(Self.self).removeAllDeliveredNotifications"), + removeAllPendingNotificationRequests: unimplemented( + "\(Self.self).removeAllPendingNotificationRequests" + ), + removeDeliveredNotificationsWithIdentifiers: unimplemented( + "\(Self.self).removeDeliveredNotificationsWithIdentifiers" + ), + removePendingNotificationRequestsWithIdentifiers: unimplemented( + "\(Self.self).removePendingNotificationRequestsWithIdentifiers" + ), + requestAuthorization: unimplemented("\(Self.self).requestAuthorization", placeholder: false), + setNotificationCategories: unimplemented("\(Self.self).setNotificationCategories"), + supportsContentExtensions: unimplemented( + "\(Self.self).supportsContentExtensions", placeholder: false + ), + delegate: unimplemented("\(Self.self).delegate", placeholder: .finished) + ) + #else // tvOS + public static let testValue = Self( + add: unimplemented("\(Self.self).add"), + pendingNotificationRequests: unimplemented("\(Self.self).pendingNotificationRequests"), + removeAllPendingNotificationRequests: unimplemented( + "\(Self.self).removeAllPendingNotificationRequests" + ), + removePendingNotificationRequestsWithIdentifiers: unimplemented( + "\(Self.self).removePendingNotificationRequestsWithIdentifiers"), + requestAuthorization: unimplemented("\(Self.self).requestAuthorization", placeholder: false), + supportsContentExtensions: unimplemented( + "\(Self.self).supportsContentExtensions", placeholder: false + ), + delegate: unimplemented("\(Self.self).delegate", placeholder: .finished) + ) + #endif } extension UserNotificationClient { -#if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) - public static let noop = Self( - add: { _ in }, - deliveredNotifications: { [] }, - notificationCategories: { [] }, - notificationSettings: unimplemented("\(Self.self).notificationSettings"), - pendingNotificationRequests: { [] }, - removeAllDeliveredNotifications: { }, - removeAllPendingNotificationRequests: { }, - removeDeliveredNotificationsWithIdentifiers: { _ in }, - removePendingNotificationRequestsWithIdentifiers: { _ in }, - requestAuthorization: { _ in false }, - setNotificationCategories: { _ in }, - supportsContentExtensions: { false }, - delegate: { AsyncStream { _ in } } - ) -#else // tvOS - public static let noop = Self( - add: { _ in }, - pendingNotificationRequests: { [] }, - removeAllPendingNotificationRequests: { }, - removePendingNotificationRequestsWithIdentifiers: { _ in }, - requestAuthorization: { _ in false }, - supportsContentExtensions: { false }, - delegate: { AsyncStream { _ in } } - ) -#endif + #if os(iOS) || os(macOS) || os(watchOS) || targetEnvironment(macCatalyst) + public static let noop = Self( + add: { _ in }, + deliveredNotifications: { [] }, + notificationCategories: { [] }, + notificationSettings: unimplemented("\(Self.self).notificationSettings"), + pendingNotificationRequests: { [] }, + removeAllDeliveredNotifications: {}, + removeAllPendingNotificationRequests: {}, + removeDeliveredNotificationsWithIdentifiers: { _ in }, + removePendingNotificationRequestsWithIdentifiers: { _ in }, + requestAuthorization: { _ in false }, + setNotificationCategories: { _ in }, + supportsContentExtensions: { false }, + delegate: { AsyncStream { _ in } } + ) + #else // tvOS + public static let noop = Self( + add: { _ in }, + pendingNotificationRequests: { [] }, + removeAllPendingNotificationRequests: {}, + removePendingNotificationRequestsWithIdentifiers: { _ in }, + requestAuthorization: { _ in false }, + supportsContentExtensions: { false }, + delegate: { AsyncStream { _ in } } + ) + #endif } diff --git a/Tests/ComposableUserNotificationsTests/ComposableUserNotificationsTests.swift b/Tests/ComposableUserNotificationsTests/ComposableUserNotificationsTests.swift index 221dee2..8b7947b 100644 --- a/Tests/ComposableUserNotificationsTests/ComposableUserNotificationsTests.swift +++ b/Tests/ComposableUserNotificationsTests/ComposableUserNotificationsTests.swift @@ -1,15 +1,16 @@ import XCTest + @testable import ComposableUserNotifications final class ComposableUserNotificationsTests: XCTestCase { - func testExample() { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct - // results. - XCTAssertEqual(true, true) - } + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + XCTAssertEqual(true, true) + } - static var allTests = [ - ("testExample", testExample), - ] + static var allTests = [ + ("testExample", testExample) + ] } diff --git a/Tests/ComposableUserNotificationsTests/XCTestManifests.swift b/Tests/ComposableUserNotificationsTests/XCTestManifests.swift index 54bd6ac..a89ad91 100644 --- a/Tests/ComposableUserNotificationsTests/XCTestManifests.swift +++ b/Tests/ComposableUserNotificationsTests/XCTestManifests.swift @@ -1,9 +1,9 @@ import XCTest #if !canImport(ObjectiveC) -public func allTests() -> [XCTestCaseEntry] { + public func allTests() -> [XCTestCaseEntry] { return [ - testCase(ComposableUserNotificationsTests.allTests), + testCase(ComposableUserNotificationsTests.allTests) ] -} + } #endif