Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmitrevski committed Dec 7, 2023
1 parent 18fa36f commit ea71f33
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,20 @@ class ChatChannelViewModel_Tests: StreamChatTestCase {
// Then
XCTAssert(shouldJump == false)
}

func test_chatChannelVM_jumpToUnknownMessage() {
// Given
let message1 = ChatMessage.mock()
let message2 = ChatMessage.mock()
let channelController = makeChannelController(messages: [message1, message2])
let viewModel = ChatChannelViewModel(channelController: channelController)

// When
let shouldJump = viewModel.jumpToMessage(messageId: .unknownMessageId)

// Then
XCTAssert(shouldJump == false)
}

// MARK: - private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MessageActions_Tests: StreamChatTestCase {
XCTAssert(messageActions[1].title == "Thread Reply")
XCTAssert(messageActions[2].title == "Pin to conversation")
XCTAssert(messageActions[3].title == "Copy Message")
XCTAssert(messageActions[4].title == "Mark Unread")
XCTAssert(messageActions[4].title == "Mark Unread")
XCTAssert(messageActions[5].title == "Flag Message")
XCTAssert(messageActions[6].title == "Mute User")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,32 @@ class MessageListView_Tests: StreamChatTestCase {
// Then
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
}

func test_messageListView_jumpToUnreadButton() {
// Given
let channelConfig = ChannelConfig(reactionsEnabled: true)
let view = makeMessageListView(
channelConfig: channelConfig,
unreadCount: .mock(messages: 3)
)
.applyDefaultSize()

// Then
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
}

// MARK: - private

func makeMessageListView(
channelConfig: ChannelConfig,
unreadCount: ChannelUnreadCount = .noUnread,
currentlyTypingUsers: Set<ChatUser> = []
) -> MessageListView<DefaultViewFactory> {
let reactions = [MessageReactionType(rawValue: "like"): 2]
let channel = ChatChannel.mockDMChannel(
config: channelConfig,
currentlyTypingUsers: currentlyTypingUsers
currentlyTypingUsers: currentlyTypingUsers,
unreadCount: unreadCount
)
let temp = [ChatMessage.mock(
id: .unique,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ea71f33

Please sign in to comment.