Skip to content

Commit 233f686

Browse files
committed
Add Unit Test
1 parent 7151146 commit 233f686

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

AztecTests/TextKit/HTMLStorageTests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,22 @@ class HTMLStorageTests: XCTestCase {
6363
XCTAssertEqual(openingTagColor, HTMLStorage.Styles.defaultTagColor)
6464
XCTAssertEqual(closingTagColor, HTMLStorage.Styles.defaultTagColor)
6565
}
66+
67+
func testSetTextColor() {
68+
let font = UIFont.boldSystemFont(ofSize: 12)
69+
let storage = HTMLStorage(defaultFont: font)
70+
let initialString = "Hello there"
71+
72+
storage.insert(NSAttributedString(string: initialString), at: 0)
73+
74+
XCTAssertEqual(storage.string, initialString)
75+
XCTAssertEqual(storage.textColor, HTMLStorage.Styles.defaultTextColor)
76+
77+
storage.textColor = .red
78+
storage.replaceCharacters(in: NSRange(location: 0, length: 4), with: NSAttributedString(string: "Hello world"))
79+
80+
let textColor = storage.attribute(.foregroundColor, at: 0, effectiveRange: nil) as! UIColor
81+
82+
XCTAssertEqual(textColor, UIColor.red)
83+
}
6684
}

0 commit comments

Comments
 (0)