mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +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:
@@ -14,8 +14,9 @@ import Testing
|
||||
final class MediaUploadPreviewScreenViewModelTests {
|
||||
var timelineProxy: TimelineProxyMock!
|
||||
var clientProxy: ClientProxyMock!
|
||||
var userIndicatorController: UserIndicatorControllerMock!
|
||||
|
||||
var userIndicatorController: UserIndicatorControllerMock
|
||||
private let appSettings: AppSettings
|
||||
|
||||
var viewModel: MediaUploadPreviewScreenViewModel!
|
||||
var context: MediaUploadPreviewScreenViewModel.Context {
|
||||
viewModel.context
|
||||
@@ -28,9 +29,10 @@ final class MediaUploadPreviewScreenViewModelTests {
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
let appSettings = AppSettings()
|
||||
appSettings = AppSettings()
|
||||
appSettings.optimizeMediaUploads = false
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
|
||||
userIndicatorController = UserIndicatorControllerMock.default
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -289,14 +291,12 @@ final class MediaUploadPreviewScreenViewModelTests {
|
||||
if let maxUploadSizeResult {
|
||||
clientProxy.underlyingMaxMediaUploadSize = maxUploadSizeResult
|
||||
}
|
||||
|
||||
userIndicatorController = UserIndicatorControllerMock()
|
||||
|
||||
|
||||
viewModel = MediaUploadPreviewScreenViewModel(mediaURLs: urls,
|
||||
title: "Some File",
|
||||
isRoomEncrypted: true,
|
||||
shouldShowCaptionWarning: true,
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: ServiceLocator.shared.settings),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: appSettings),
|
||||
timelineController: MockTimelineController(timelineProxy: timelineProxy),
|
||||
clientProxy: clientProxy,
|
||||
userIndicatorController: userIndicatorController)
|
||||
|
||||
Reference in New Issue
Block a user