Skip to content

Commit 29bc24b

Browse files
added tests for the view factory
1 parent 0b767b8 commit 29bc24b

File tree

3 files changed

+424
-13
lines changed

3 files changed

+424
-13
lines changed

Sources/StreamChatSwiftUI/DefaultViewFactory.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import SwiftUI
1010
extension ViewFactory {
1111
// MARK: channels
1212

13-
public func makeNoChannelsView() -> NoChannelsView {
13+
public func makeNoChannelsView() -> some View {
1414
NoChannelsView()
1515
}
1616

17-
public func makeLoadingView() -> LoadingView {
17+
public func makeLoadingView() -> some View {
1818
LoadingView()
1919
}
2020

@@ -45,7 +45,7 @@ extension ViewFactory {
4545
for channel: ChatChannel,
4646
onDismiss: @escaping () -> Void,
4747
onError: @escaping (Error) -> Void
48-
) -> MoreChannelActionsView {
48+
) -> some View {
4949
MoreChannelActionsView(
5050
channel: channel,
5151
channelActions: supportedMoreChannelActions(
@@ -100,7 +100,7 @@ extension ViewFactory {
100100
}
101101
}
102102

103-
public func makeMessageAvatarView(for author: ChatUser) -> MessageAvatarView {
103+
public func makeMessageAvatarView(for author: ChatUser) -> some View {
104104
MessageAvatarView(author: author)
105105
}
106106

@@ -114,15 +114,15 @@ extension ViewFactory {
114114
for message: ChatMessage,
115115
isFirst: Bool,
116116
availableWidth: CGFloat
117-
) -> MessageTextView {
117+
) -> some View {
118118
MessageTextView(message: message, isFirst: isFirst)
119119
}
120120

121121
public func makeImageAttachmentView(
122122
for message: ChatMessage,
123123
isFirst: Bool,
124124
availableWidth: CGFloat
125-
) -> ImageAttachmentContainer {
125+
) -> some View {
126126
ImageAttachmentContainer(
127127
message: message,
128128
width: availableWidth,
@@ -134,7 +134,7 @@ extension ViewFactory {
134134
for message: ChatMessage,
135135
isFirst: Bool,
136136
availableWidth: CGFloat
137-
) -> GiphyAttachmentView {
137+
) -> some View {
138138
GiphyAttachmentView(
139139
message: message,
140140
width: availableWidth,
@@ -146,7 +146,7 @@ extension ViewFactory {
146146
for message: ChatMessage,
147147
isFirst: Bool,
148148
availableWidth: CGFloat
149-
) -> LinkAttachmentContainer {
149+
) -> some View {
150150
LinkAttachmentContainer(
151151
message: message,
152152
width: availableWidth,
@@ -158,7 +158,7 @@ extension ViewFactory {
158158
for message: ChatMessage,
159159
isFirst: Bool,
160160
availableWidth: CGFloat
161-
) -> FileAttachmentsContainer {
161+
) -> some View {
162162
FileAttachmentsContainer(
163163
message: message,
164164
width: availableWidth,
@@ -170,7 +170,7 @@ extension ViewFactory {
170170
for message: ChatMessage,
171171
isFirst: Bool,
172172
availableWidth: CGFloat
173-
) -> VideoAttachmentsContainer {
173+
) -> some View {
174174
VideoAttachmentsContainer(
175175
message: message,
176176
width: availableWidth
@@ -181,7 +181,7 @@ extension ViewFactory {
181181
for message: ChatMessage,
182182
isFirst: Bool,
183183
availableWidth: CGFloat
184-
) -> DeletedMessageView {
184+
) -> some View {
185185
DeletedMessageView(
186186
message: message,
187187
isFirst: isFirst
@@ -192,14 +192,14 @@ extension ViewFactory {
192192
for message: ChatMessage,
193193
isFirst: Bool,
194194
availableWidth: CGFloat
195-
) -> EmptyView {
195+
) -> some View {
196196
EmptyView()
197197
}
198198

199199
public func makeGiphyBadgeViewType(
200200
for message: ChatMessage,
201201
availableWidth: CGFloat
202-
) -> GiphyBadgeView {
202+
) -> some View {
203203
GiphyBadgeView()
204204
}
205205

StreamChatSwiftUI.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
84C94D5A275A2E43007FE2B9 /* StreamChat_Utils_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D59275A2E43007FE2B9 /* StreamChat_Utils_Tests.swift */; };
219219
84C94D5C275A2E9F007FE2B9 /* StreamChatUtilsMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D5B275A2E9F007FE2B9 /* StreamChatUtilsMocks.swift */; };
220220
84C94D5E275A3AA9007FE2B9 /* ImageCDN_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D5D275A3AA9007FE2B9 /* ImageCDN_Tests.swift */; };
221+
84C94D60275A45D2007FE2B9 /* ViewFactory_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C94D5F275A45D2007FE2B9 /* ViewFactory_Tests.swift */; };
221222
84EDBC37274FE5CD0057218D /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 84EDBC36274FE5CD0057218D /* Localizable.strings */; };
222223
/* End PBXBuildFile section */
223224

@@ -466,6 +467,7 @@
466467
84C94D59275A2E43007FE2B9 /* StreamChat_Utils_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamChat_Utils_Tests.swift; sourceTree = "<group>"; };
467468
84C94D5B275A2E9F007FE2B9 /* StreamChatUtilsMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamChatUtilsMocks.swift; sourceTree = "<group>"; };
468469
84C94D5D275A3AA9007FE2B9 /* ImageCDN_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCDN_Tests.swift; sourceTree = "<group>"; };
470+
84C94D5F275A45D2007FE2B9 /* ViewFactory_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewFactory_Tests.swift; sourceTree = "<group>"; };
469471
84EDBC36274FE5CD0057218D /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = "<group>"; };
470472
/* End PBXFileReference section */
471473

@@ -987,6 +989,7 @@
987989
84C94D55275A1AE1007FE2B9 /* StringExtensions_Tests.swift */,
988990
84C94D59275A2E43007FE2B9 /* StreamChat_Utils_Tests.swift */,
989991
84C94D5D275A3AA9007FE2B9 /* ImageCDN_Tests.swift */,
992+
84C94D5F275A45D2007FE2B9 /* ViewFactory_Tests.swift */,
990993
);
991994
path = Utils;
992995
sourceTree = "<group>";
@@ -1293,6 +1296,7 @@
12931296
84C94CE427578B92007FE2B9 /* ChatChannelController_Mock.swift in Sources */,
12941297
84C94D58275A1B89007FE2B9 /* MessageTypeResolver_Tests.swift in Sources */,
12951298
84C94D282757954C007FE2B9 /* VirtualTimer.swift in Sources */,
1299+
84C94D60275A45D2007FE2B9 /* ViewFactory_Tests.swift in Sources */,
12961300
84C94D442757C704007FE2B9 /* MoreChannelActionsViewModel_Tests.swift in Sources */,
12971301
84C94D5127591DE2007FE2B9 /* ChatMessageIDs_Tests.swift in Sources */,
12981302
84C94CD727578B92007FE2B9 /* ChatMessageLinkAttachment_Mock.swift in Sources */,

0 commit comments

Comments
 (0)