mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
22d14ff8e4
* create DependenciesProtocol and replace ServiceLocator registration with it replace mocking calls for ServiceLocator to Dependencies replace ServiceLocator with instance level calls replace ServiceLocator configs with TestDependencies config in Tests replace servicelocator usage in analytics service replace remaining ServiceLocator calls in unit tests that depended on the UnitTestAppCoordinator configuration with per suite dependencies instances fix swiftlint warning remove remaining references to ServiceLocator make dependencies properties consistent in tests delete Dependencies and DependenciesProtocol fix whitespace modifications updates from PR feedback a pass over converting AppSettings and AnalyticsService test instance properties to per test instantiation fix a missed PR feedback Sync up after rebase create DependenciesProtocol and replace ServiceLocator registration with it replace mocking calls for ServiceLocator to Dependencies replace ServiceLocator with instance level calls replace ServiceLocator configs with TestDependencies config in Tests replace servicelocator usage in analytics service replace remaining ServiceLocator calls in unit tests that depended on the UnitTestAppCoordinator configuration with per suite dependencies instances fix swiftlint warning remove remaining references to ServiceLocator make dependencies properties consistent in tests delete Dependencies and DependenciesProtocol * AppSettings is instance level mockable now * replace mocked and preview usages of reset + AppSettings global init with AppSettings(store: UserDefaultsMock()) * AppSettings.UserDefaultsKeys is now a RawRep struct, making it extensible * update tests with new AppSettings so it builds * update remaining AppSettings test/mock inits * AppSettings.UserDefaultsKey conformed to ExpressibleByStringLiteral * addressed issues found in first pass ai review * update AppSettings instantiations after rebase * fix accessibility tests coordinator after rebase * Rename to VolatileUserDefaults * AppSettings init uses mandatory parameter * Revert UserDefaultsKey to enum * Add TrackedUserDefaults to be able to reset the defaults object * Added volatile static func to AppSettings * Use .volatile() static func instead of full init * review fixups * Resolve build issues after rebase * updated enterprise module * remove the static reset settings call from the preview tests --------- Co-authored-by: Mauro Romito <mauro.romito@element.io>
49 lines
1.6 KiB
Swift
49 lines
1.6 KiB
Swift
//
|
|
// Copyright 2025 Element Creations Ltd.
|
|
// Copyright 2022-2025 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
|
// Please see LICENSE files in the repository root for full details.
|
|
//
|
|
|
|
import Combine
|
|
@testable import ElementX
|
|
import Testing
|
|
|
|
@MainActor
|
|
struct SettingsScreenViewModelTests {
|
|
private var viewModel: SettingsScreenViewModelProtocol
|
|
private var context: SettingsScreenViewModelType.Context
|
|
|
|
init() {
|
|
let appSettings = AppSettings.volatile()
|
|
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: ""))))
|
|
viewModel = SettingsScreenViewModel(userSession: userSession,
|
|
appSettings: appSettings,
|
|
isBugReportServiceEnabled: true,
|
|
isInSecondaryWindow: false)
|
|
context = viewModel.context
|
|
}
|
|
|
|
@Test
|
|
func logout() async throws {
|
|
let deferred = deferFulfillment(viewModel.actions) { $0 == .logout }
|
|
context.send(viewAction: .logout)
|
|
try await deferred.fulfill()
|
|
}
|
|
|
|
@Test
|
|
func reportBug() async throws {
|
|
let deferred = deferFulfillment(viewModel.actions) { $0 == .reportBug }
|
|
context.send(viewAction: .reportBug)
|
|
try await deferred.fulfill()
|
|
}
|
|
|
|
@Test
|
|
func analytics() async throws {
|
|
let deferred = deferFulfillment(viewModel.actions) { $0 == .analytics }
|
|
context.send(viewAction: .analytics)
|
|
try await deferred.fulfill()
|
|
}
|
|
}
|