mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Replace the ServiceLocator with direct dependency injection (#5548)
Removes the ServiceLocator singleton and instead directly injects the dependencies it was holding for more control over instantiation of the various component subtrees and better visibility over how they're being used.
This commit is contained in:
@@ -11,20 +11,19 @@ import Testing
|
||||
|
||||
@MainActor
|
||||
final class AnalyticsSettingsScreenViewModelTests {
|
||||
private var appSettings: AppSettings!
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
|
||||
private var viewModel: AnalyticsSettingsScreenViewModelProtocol!
|
||||
private var context: AnalyticsSettingsScreenViewModelType.Context!
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
let analyticsClient = AnalyticsClientMock()
|
||||
analyticsClient.isRunning = false
|
||||
ServiceLocator.shared.register(analytics: AnalyticsService(client: analyticsClient,
|
||||
appSettings: appSettings))
|
||||
|
||||
analytics = .mock(settings: appSettings)
|
||||
|
||||
viewModel = AnalyticsSettingsScreenViewModel(appSettings: appSettings,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: analytics)
|
||||
context = viewModel.context
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user