-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into change/add-additional-space-when-mentioni…
…ng-user
- Loading branch information
Showing
12 changed files
with
162 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+42.4 KB
...elVC_Tests/test_onlyEmojiMessageAppearance_whenQuotingMessage.default-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.7 KB
...st_onlyEmojiMessageAppearance_whenQuotingMessage.extraExtraExtraLarge-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.4 KB
...est_onlyEmojiMessageAppearance_whenQuotingMessage.rightToLeftLayout-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41.8 KB
...annelVC_Tests/test_onlyEmojiMessageAppearance_whenQuotingMessage.small-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
Tests/StreamChatUITests/Utils/TextViewMentionedUsersHandler_Tests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// Copyright © 2023 Stream.io Inc. All rights reserved. | ||
// | ||
|
||
@testable import StreamChat | ||
@testable import StreamChatUI | ||
import XCTest | ||
|
||
final class TextViewMentionedUsersHandler_Tests: XCTestCase { | ||
func test_mentionedUserTapped_whenRangeIncludesMention() { | ||
let textView = UITextView() | ||
textView.text = "@Leia Hello!" | ||
|
||
let sut = TextViewMentionedUsersHandler() | ||
let user = sut.mentionedUserTapped( | ||
on: textView, | ||
in: .init(location: 0, length: 5), | ||
with: [.mock(id: "leia", name: "Leia")] | ||
) | ||
|
||
XCTAssertEqual(user?.name, "Leia") | ||
} | ||
|
||
func test_mentionedUserTapped_whenRangeDoesNotIncludeMention() { | ||
let textView = UITextView() | ||
textView.text = "@Leia Hello!" | ||
|
||
let sut = TextViewMentionedUsersHandler() | ||
let user = sut.mentionedUserTapped( | ||
on: textView, | ||
in: .init(location: 3, length: 7), | ||
with: [.mock(id: "leia", name: "Leia")] | ||
) | ||
|
||
XCTAssertEqual(user?.name, nil) | ||
} | ||
|
||
func test_mentionedUserTapped_whenIncludesSpecialCharacter() { | ||
let textView = UITextView() | ||
textView.text = "@Lei@ Hello!" | ||
|
||
let sut = TextViewMentionedUsersHandler() | ||
let user = sut.mentionedUserTapped( | ||
on: textView, | ||
in: .init(location: 0, length: 5), | ||
with: [.mock(id: "leia", name: "Lei@")] | ||
) | ||
|
||
XCTAssertEqual(user?.name, "Lei@") | ||
} | ||
|
||
// Customers can customise how mentions are presented, and so they can chose not to show it. | ||
func test_mentionedUserTapped_whenAtSignIsNotPresent() { | ||
let textView = UITextView() | ||
textView.text = "Lei@ Hello!" | ||
|
||
let sut = TextViewMentionedUsersHandler() | ||
let user = sut.mentionedUserTapped( | ||
on: textView, | ||
in: .init(location: 0, length: 5), | ||
with: [.mock(id: "leia", name: "Lei@")] | ||
) | ||
|
||
XCTAssertEqual(user?.name, "Lei@") | ||
} | ||
|
||
func test_mentionedUserTapped_whenUserDoesNotHaveName() { | ||
let textView = UITextView() | ||
textView.text = "leia Hello!" | ||
|
||
let sut = TextViewMentionedUsersHandler() | ||
let user = sut.mentionedUserTapped( | ||
on: textView, | ||
in: .init(location: 0, length: 5), | ||
with: [.mock(id: "leia", name: nil)] | ||
) | ||
|
||
XCTAssertEqual(user?.id, "leia") | ||
} | ||
} |