mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Update files following swiftformat upgrade
This commit is contained in:
committed by
Stefan Ceriu
parent
fe189fcfed
commit
23062901c0
@@ -13,6 +13,11 @@ final class MockCoder: NSKeyedArchiver {
|
||||
finishEncoding()
|
||||
}
|
||||
|
||||
override func decodeObject(forKey _: String) -> Any { "" }
|
||||
override func decodeInt64(forKey key: String) -> Int64 { 0 }
|
||||
override func decodeObject(forKey _: String) -> Any {
|
||||
""
|
||||
}
|
||||
|
||||
override func decodeInt64(forKey key: String) -> Int64 {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@
|
||||
//
|
||||
|
||||
import Combine
|
||||
@testable import ElementX
|
||||
import NotificationCenter
|
||||
import XCTest
|
||||
|
||||
@testable import ElementX
|
||||
|
||||
@MainActor
|
||||
final class NotificationManagerTests: XCTestCase {
|
||||
var notificationManager: NotificationManager!
|
||||
@@ -24,7 +23,9 @@ final class NotificationManagerTests: XCTestCase {
|
||||
private var notificationTappedDelegateCalled = false
|
||||
private var registerForRemoteNotificationsDelegateCalled: (() -> Void)?
|
||||
|
||||
private var appSettings: AppSettings { ServiceLocator.shared.settings }
|
||||
private var appSettings: AppSettings {
|
||||
ServiceLocator.shared.settings
|
||||
}
|
||||
|
||||
override func setUp() {
|
||||
AppSettings.resetAllSettings()
|
||||
@@ -49,12 +50,12 @@ final class NotificationManagerTests: XCTestCase {
|
||||
XCTAssertTrue(clientProxy.setPusherWithCalled)
|
||||
}
|
||||
|
||||
func test_whenRegisteredSuccess_completionSuccessIsCalled() async throws {
|
||||
func test_whenRegisteredSuccess_completionSuccessIsCalled() async {
|
||||
let success = await notificationManager.register(with: Data())
|
||||
XCTAssertTrue(success)
|
||||
}
|
||||
|
||||
func test_whenRegisteredAndPusherThrowsError_completionFalseIsCalled() async throws {
|
||||
func test_whenRegisteredAndPusherThrowsError_completionFalseIsCalled() async {
|
||||
enum TestError: Error {
|
||||
case someError
|
||||
}
|
||||
@@ -92,13 +93,13 @@ final class NotificationManagerTests: XCTestCase {
|
||||
XCTAssertEqual(data.defaultPayload, try defaultPayload.toJsonString())
|
||||
}
|
||||
|
||||
func test_whenRegisteredAndPusherTagNotSetInSettings_tagGeneratedAndSavedInSettings() async throws {
|
||||
func test_whenRegisteredAndPusherTagNotSetInSettings_tagGeneratedAndSavedInSettings() async {
|
||||
appSettings.pusherProfileTag = nil
|
||||
_ = await notificationManager.register(with: Data())
|
||||
XCTAssertNotNil(appSettings.pusherProfileTag)
|
||||
}
|
||||
|
||||
func test_whenRegisteredAndPusherTagIsSetInSettings_tagNotGenerated() async throws {
|
||||
func test_whenRegisteredAndPusherTagIsSetInSettings_tagNotGenerated() async {
|
||||
appSettings.pusherProfileTag = "12345"
|
||||
_ = await notificationManager.register(with: Data())
|
||||
XCTAssertEqual(appSettings.pusherProfileTag, "12345")
|
||||
@@ -111,7 +112,7 @@ final class NotificationManagerTests: XCTestCase {
|
||||
XCTAssertEqual(request.content.subtitle, "Subtitle")
|
||||
}
|
||||
|
||||
func test_whenStart_notificationCategoriesAreSet() throws {
|
||||
func test_whenStart_notificationCategoriesAreSet() {
|
||||
let replyAction = UNTextInputNotificationAction(identifier: NotificationConstants.Action.inlineReply,
|
||||
title: L10n.actionQuickReply,
|
||||
options: [])
|
||||
@@ -132,7 +133,7 @@ final class NotificationManagerTests: XCTestCase {
|
||||
XCTAssertTrue(delegate.isEqual(notificationManager))
|
||||
}
|
||||
|
||||
func test_whenStart_requestAuthorizationCalledWithCorrectParams() async throws {
|
||||
func test_whenStart_requestAuthorizationCalledWithCorrectParams() async {
|
||||
let expectation = expectation(description: "requestAuthorization should be called")
|
||||
notificationCenter.requestAuthorizationOptionsClosure = { _ in
|
||||
expectation.fulfill()
|
||||
@@ -143,7 +144,7 @@ final class NotificationManagerTests: XCTestCase {
|
||||
XCTAssertEqual(notificationCenter.requestAuthorizationOptionsReceivedOptions, [.alert, .sound, .badge])
|
||||
}
|
||||
|
||||
func test_whenStartAndAuthorizationGranted_delegateCalled() async throws {
|
||||
func test_whenStartAndAuthorizationGranted_delegateCalled() async {
|
||||
authorizationStatusWasGranted = false
|
||||
notificationManager.delegate = self
|
||||
let expectation: XCTestExpectation = expectation(description: "registerForRemoteNotifications delegate function should be called")
|
||||
@@ -167,7 +168,7 @@ final class NotificationManagerTests: XCTestCase {
|
||||
XCTAssertFalse(authorizationStatusWasGranted)
|
||||
}
|
||||
|
||||
func test_whenStartAndAuthorized_registerForRemoteNotificationsCalled() async throws {
|
||||
func test_whenStartAndAuthorized_registerForRemoteNotificationsCalled() async {
|
||||
appSettings.enableNotifications = true
|
||||
notificationCenter.authorizationStatusReturnValue = .authorized
|
||||
notificationManager.delegate = self
|
||||
|
||||
Reference in New Issue
Block a user