Skip to content

Commit 2efa3e4

Browse files
committed
Add test to check reset of text attributes when deleting all text.
1 parent 3301a51 commit 2efa3e4

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

AztecTests/TextKit/TextViewTests.swift

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

2081+
/// Check if pasting attributed text without color, the color is set to default color
20812082
func testPasteAttributedText() {
20822083
let sourceAttributedText = NSAttributedString(string: "Hello world")
20832084
var pasteItems = [String:Any]()
@@ -2095,4 +2096,14 @@ class TextViewTests: XCTestCase {
20952096
XCTAssertEqual(textView.text, "Hello world")
20962097
}
20972098

2099+
/// Check that deleting all text resets the typying attributes to the default attributes
2100+
func testDeleteAllTextSetTypyingAttributesToDefault() {
2101+
let textView = TextViewStub(withHTML: "<p style=\"color:0xFF0000\">Hello world</p>")
2102+
textView.defaultTextColor = UIColor.green
2103+
textView.selectedRange = textView.attributedText!.rangeOfEntireString
2104+
textView.deleteBackward()
2105+
let attributes = textView.typingAttributes
2106+
XCTAssertEqual(attributes[.foregroundColor] as! UIColor,UIColor.green)
2107+
}
2108+
20982109
}

0 commit comments

Comments
 (0)