Skip to content

Commit

Permalink
Emoji fix (#44)
Browse files Browse the repository at this point in the history
* Fix Emoji in HighlightedTextEditor

* Tests typing emojis

* UIKit test for emoji fix

* Removes sleep

* Simplifies macOS emoji test

Co-authored-by: ceojosef <79390260+ceojosef@users.noreply.github.com>
  • Loading branch information
kyle-n and ceojosef authored May 28, 2021
1 parent e7f0db3 commit 3eff60b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/HighlightedTextEditor/HighlightingTextEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ extension HighlightingTextEditor {

static func getHighlightedText(text: String, highlightRules: [HighlightRule]) -> NSMutableAttributedString {
let highlightedString = NSMutableAttributedString(string: text)
let all = NSRange(location: 0, length: text.count)
let all = NSRange(location: 0, length: text.utf16.count)

let editorFont = defaultEditorFont
let editorTextColor = defaultEditorTextColor
Expand Down
19 changes: 19 additions & 0 deletions Tests/Essayist/iOS-EssayistUITests/iOS_EssayistUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,23 @@ class iOS_EssayistUITests: XCTestCase {
textView.tap()
XCTAssertTrue(aKey.waitForExistence(timeout: 2))
}

func testTypingEmoji() {
let app = XCUIApplication()
app.launch()

selectEditor(.blank)

let textView = app.textViews.firstMatch
_ = textView.waitForExistence(timeout: 2)

UIPasteboard.general.string = "💩"

textView.tap()
textView.doubleTap()
app.menuItems["Paste"].tap()

let textViewContent = textView.value as! String
XCTAssertEqual(textViewContent, "💩")
}
}
16 changes: 16 additions & 0 deletions Tests/Essayist/macOS-EssayistUITests/macOS_EssayistUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ class macOS_EssayistUITests: XCTestCase {
XCTAssertTrue(selectionChangesExists)
}

func testTypingEmoji() {
let app = XCUIApplication()
app.activate()

selectEditor(.blank)

let window = app.windows.firstMatch
let textView = window.textViews.firstMatch

textView.click()
textView.typeText("💩")

let textViewContent = textView.value as! String
XCTAssertEqual(textViewContent, "💩")
}

func testIntrospect() {
let app = XCUIApplication()
app.activate()
Expand Down

0 comments on commit 3eff60b

Please sign in to comment.