Skip to content

Commit 3c1becb

Browse files
added snapshot tests
1 parent 9bf2ac4 commit 3c1becb

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed

StreamChatSwiftUITests/Tests/ChatChannel/MessageView_Tests.swift

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,96 @@ class MessageView_Tests: XCTestCase {
6767
// Then
6868
assertSnapshot(matching: view, as: .image)
6969
}
70+
71+
func test_messageViewGiphy_snapshot() {
72+
// Given
73+
let giphyMessage = ChatMessage.mock(
74+
id: .unique,
75+
cid: .unique,
76+
text: "",
77+
author: .mock(id: .unique),
78+
attachments: ChatChannelTestHelpers.giphyAttachments
79+
)
80+
81+
// When
82+
let view = MessageView(
83+
factory: DefaultViewFactory.shared,
84+
message: giphyMessage,
85+
contentWidth: defaultScreenSize.width,
86+
isFirst: true
87+
)
88+
.frame(width: defaultScreenSize.width, height: defaultScreenSize.height)
89+
90+
// Then
91+
assertSnapshot(matching: view, as: .image)
92+
}
93+
94+
func test_messageViewLink_snapshot() {
95+
// Given
96+
let linkMessage = ChatMessage.mock(
97+
id: .unique,
98+
cid: .unique,
99+
text: "",
100+
author: .mock(id: .unique),
101+
attachments: ChatChannelTestHelpers.linkAttachments
102+
)
103+
104+
// When
105+
let view = MessageView(
106+
factory: DefaultViewFactory.shared,
107+
message: linkMessage,
108+
contentWidth: defaultScreenSize.width,
109+
isFirst: true
110+
)
111+
.frame(width: defaultScreenSize.width, height: defaultScreenSize.height)
112+
113+
// Then
114+
assertSnapshot(matching: view, as: .image)
115+
}
116+
117+
func test_messageViewVideo_snapshot() {
118+
// Given
119+
let videoMessage = ChatMessage.mock(
120+
id: .unique,
121+
cid: .unique,
122+
text: "",
123+
author: .mock(id: .unique),
124+
attachments: ChatChannelTestHelpers.videoAttachments
125+
)
126+
127+
// When
128+
let view = MessageView(
129+
factory: DefaultViewFactory.shared,
130+
message: videoMessage,
131+
contentWidth: defaultScreenSize.width,
132+
isFirst: true
133+
)
134+
.frame(width: defaultScreenSize.width, height: defaultScreenSize.height)
135+
136+
// Then
137+
assertSnapshot(matching: view, as: .image)
138+
}
139+
140+
func test_messageViewFile_snapshot() {
141+
// Given
142+
let fileMessage = ChatMessage.mock(
143+
id: .unique,
144+
cid: .unique,
145+
text: "",
146+
author: .mock(id: .unique),
147+
attachments: ChatChannelTestHelpers.fileAttachments
148+
)
149+
150+
// When
151+
let view = MessageView(
152+
factory: DefaultViewFactory.shared,
153+
message: fileMessage,
154+
contentWidth: defaultScreenSize.width,
155+
isFirst: true
156+
)
157+
.frame(width: defaultScreenSize.width, height: defaultScreenSize.height)
158+
159+
// Then
160+
assertSnapshot(matching: view, as: .image)
161+
}
70162
}
60.3 KB
Loading
61 KB
Loading
62.6 KB
Loading
52.1 KB
Loading

0 commit comments

Comments
 (0)