Skip to content

Commit 3301a51

Browse files
committed
Add test to check if paste of attribute text sets default color.
1 parent d44884c commit 3301a51

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

AztecTests/TextKit/TextViewTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,4 +2078,21 @@ class TextViewTests: XCTestCase {
20782078
XCTAssertEqual(UIPasteboard.general.html(), "<p><strong>bol</strong></p>")
20792079
}
20802080

2081+
func testPasteAttributedText() {
2082+
let sourceAttributedText = NSAttributedString(string: "Hello world")
2083+
var pasteItems = [String:Any]()
2084+
pasteItems[kUTTypePlainText as String] = try! sourceAttributedText.data(from: sourceAttributedText.rangeOfEntireString, documentAttributes: [.documentType: DocumentType.plain])
2085+
UIPasteboard.general.setItems([pasteItems], options: [:])
2086+
let textView = TextViewStub(withHTML: "")
2087+
textView.defaultTextColor = UIColor.red
2088+
textView.paste(nil)
2089+
2090+
let attributedString = textView.attributedText!
2091+
2092+
let attributes = attributedString.attributes(at: 0, effectiveRange: nil)
2093+
2094+
XCTAssertEqual(attributes[.foregroundColor] as! UIColor, UIColor.red)
2095+
XCTAssertEqual(textView.text, "Hello world")
2096+
}
2097+
20812098
}

0 commit comments

Comments
 (0)