mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 19:44:05 +00:00
Make AnalyticsService mockable via `AnalyticsServiceProtocol (#5599)
* Create AnalyticsServiceProtocol and conform AnalyticsService * Replace AnalyticsService properties and arguments with AnalyticsServiceProtocol * Inline AnalyticsServiceMock replacing old mock * handle more complex AnalyticsServiceMock callsites * move documentation from AnalyticsService to AnalyticsServiceProtocol
This commit is contained in:
@@ -16,7 +16,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func user() async {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let id = "@test:matrix.org"
|
||||
@@ -30,7 +29,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -51,7 +50,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func ownUser() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let id = "@test:matrix.org"
|
||||
@@ -65,7 +63,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -77,7 +75,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func allUsers() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let avatarURL = URL(string: "https://matrix.jpg")
|
||||
@@ -93,7 +90,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -106,7 +103,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func roomIDMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -121,7 +117,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -135,7 +131,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func roomIDMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -148,7 +143,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -162,7 +157,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func roomAliasMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -179,7 +173,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -193,7 +187,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func roomAliasMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -206,7 +199,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -220,7 +213,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func eventOnRoomIDMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -235,7 +227,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -249,7 +241,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func eventOnRoomIDMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -262,7 +253,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -276,7 +267,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func eventOnRoomAliasMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -293,7 +283,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -307,7 +297,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func eventOnRoomAliasMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -320,7 +309,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
|
||||
Reference in New Issue
Block a user