Skip to content

Commit 17e4521

Browse files
Added tests for image attachments views
1 parent a406fbc commit 17e4521

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

StreamChatSwiftUITests/Tests/ChatChannel/MessageView_Tests.swift

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,92 @@ class MessageView_Tests: StreamChatTestCase {
5757
assertSnapshot(matching: view, as: .image)
5858
}
5959

60+
func test_messageViewImage_snapshot2Images() {
61+
// Given
62+
let imageMessage = ChatMessage.mock(
63+
id: .unique,
64+
cid: .unique,
65+
text: "test message",
66+
author: .mock(id: .unique),
67+
attachments: [
68+
ChatChannelTestHelpers.imageAttachments[0],
69+
ChatChannelTestHelpers.imageAttachments[0]
70+
]
71+
)
72+
73+
// When
74+
let view = MessageView(
75+
factory: DefaultViewFactory.shared,
76+
message: imageMessage,
77+
contentWidth: defaultScreenSize.width,
78+
isFirst: true,
79+
scrolledId: .constant(nil)
80+
)
81+
.applyDefaultSize()
82+
83+
// Then
84+
assertSnapshot(matching: view, as: .image)
85+
}
86+
87+
func test_messageViewImage_snapshot3Images() {
88+
// Given
89+
let imageMessage = ChatMessage.mock(
90+
id: .unique,
91+
cid: .unique,
92+
text: "test message",
93+
author: .mock(id: .unique),
94+
attachments: [
95+
ChatChannelTestHelpers.imageAttachments[0],
96+
ChatChannelTestHelpers.imageAttachments[0],
97+
ChatChannelTestHelpers.imageAttachments[0]
98+
]
99+
)
100+
101+
// When
102+
let view = MessageView(
103+
factory: DefaultViewFactory.shared,
104+
message: imageMessage,
105+
contentWidth: defaultScreenSize.width,
106+
isFirst: true,
107+
scrolledId: .constant(nil)
108+
)
109+
.applyDefaultSize()
110+
111+
// Then
112+
assertSnapshot(matching: view, as: .image)
113+
}
114+
115+
func test_messageViewImage_snapshotQuoted() {
116+
// Given
117+
let quoted = ChatMessage.mock(
118+
id: .unique,
119+
cid: .unique,
120+
text: "This is a quoted message",
121+
author: .mock(id: .unique)
122+
)
123+
let imageMessage = ChatMessage.mock(
124+
id: .unique,
125+
cid: .unique,
126+
text: "test message",
127+
author: .mock(id: .unique),
128+
quotedMessage: quoted,
129+
attachments: ChatChannelTestHelpers.imageAttachments
130+
)
131+
132+
// When
133+
let view = MessageView(
134+
factory: DefaultViewFactory.shared,
135+
message: imageMessage,
136+
contentWidth: defaultScreenSize.width,
137+
isFirst: true,
138+
scrolledId: .constant(nil)
139+
)
140+
.applyDefaultSize()
141+
142+
// Then
143+
assertSnapshot(matching: view, as: .image)
144+
}
145+
60146
func test_messageViewGiphy_snapshot() {
61147
// Given
62148
let giphyMessage = ChatMessage.mock(
Loading
Loading
Loading

0 commit comments

Comments
 (0)