From 11cd0f8bb660d8e11ed5c47e1911485cc13d5856 Mon Sep 17 00:00:00 2001 From: martinmitrevski Date: Mon, 27 Nov 2023 10:17:43 +0100 Subject: [PATCH] Added tests --- .../ChatChannelViewModel_Tests.swift | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/StreamChatSwiftUITests/Tests/ChatChannel/ChatChannelViewModel_Tests.swift b/StreamChatSwiftUITests/Tests/ChatChannel/ChatChannelViewModel_Tests.swift index a5fa2c04..ac57ae3d 100644 --- a/StreamChatSwiftUITests/Tests/ChatChannel/ChatChannelViewModel_Tests.swift +++ b/StreamChatSwiftUITests/Tests/ChatChannel/ChatChannelViewModel_Tests.swift @@ -413,6 +413,48 @@ class ChatChannelViewModel_Tests: StreamChatTestCase { // Then XCTAssert(viewModel.threadMessage == nil) } + + func test_chatChannelVM_jumpToInitialMessage() { + // Given + let message = ChatMessage.mock() + let channelController = makeChannelController(messages: [message]) + let viewModel = ChatChannelViewModel(channelController: channelController) + + // When + let shouldJump = viewModel.jumpToMessage(messageId: message.messageId) + + // Then + XCTAssert(shouldJump == true) + } + + func test_chatChannelVM_jumpToAvailableMessage() { + // 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: message2.messageId) + + // Then + XCTAssert(shouldJump == true) + } + + func test_chatChannelVM_jumpToUnavailableMessage() { + // Given + let message1 = ChatMessage.mock() + let message2 = ChatMessage.mock() + let message3 = ChatMessage.mock() + let channelController = makeChannelController(messages: [message1, message2]) + let viewModel = ChatChannelViewModel(channelController: channelController) + + // When + let shouldJump = viewModel.jumpToMessage(messageId: message3.messageId) + + // Then + XCTAssert(shouldJump == false) + } // MARK: - private