Skip to content

Commit

Permalink
Add test coverage to avoid regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-vieira committed May 20, 2024
1 parent aadb4b8 commit d1742bc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,41 @@ final class ComposerVC_Tests: XCTestCase {
XCTAssertEqual(searchUsers([user], by: "fran莽ois"), [user])
XCTAssertEqual(searchUsers([user], by: "franc"), [user])
}


// MARK: - suggestions view

func test_showCommandSuggestionsView() {
let containerView = UIViewController()
containerView.addChildViewController(composerVC, embedIn: containerView.view)
let channel = ChatChannel.mock(
cid: .unique,
config: .mock(commands: [.init(name: "giphy")])
)
mockedChatChannelController.channel_mock = channel
composerVC.content = .initial()
composerVC.content.text = "/"
composerVC.updateContent()
AssertSnapshot(containerView.view, variants: [.defaultLight], size: .init(width: 400, height: 150))
}

func test_showMentionSuggestionsView() {
let containerView = UIViewController()
containerView.addChildViewController(composerVC, embedIn: containerView.view)
let channel = ChatChannel.mock(
cid: .unique,
config: .mock(commands: [.init(name: "giphy")]),
lastActiveMembers: [.mock(id: "leia_organa", name: "Leia Organa")]
)
mockedChatChannelController.channel_mock = channel
composerVC.userSearchController = .init(client: mockedChatChannelController.client)
composerVC.userMentionsDebouncer = .init(0, queue: .main)
composerVC.content = .initial()
composerVC.content.text = "Hello @Le"
composerVC.content.mentionedUsers = [.mock(id: "leia_organa", name: "Leia Organa")]
composerVC.updateContent()
AssertSnapshot(containerView.view, variants: [.defaultLight], size: .init(width: 400, height: 130))
}

// MARK: - attachmentsPreview

func test_attachmentsPreview_withFourAttachments_addedSameTime() {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 d1742bc

Please sign in to comment.