@@ -2017,7 +2017,7 @@ class TextViewTests: XCTestCase {
20172017 XCTAssertEqual ( output, expected)
20182018 }
20192019
2020- // MARK: - Copy tests
2020+ // MARK: - Copy/Paste tests
20212021
20222022 func testCopyAndPasteToPlainText( ) {
20232023 let sourceTextView = TextViewStub ( withHTML: " This is text with attributes: <strong>bold</strong> " )
@@ -2027,4 +2027,32 @@ class TextViewTests: XCTestCase {
20272027
20282028 XCTAssertEqual ( UIPasteboard . general. string, " This is text with attributes: bold " )
20292029 }
2030+
2031+ func testCopyHTML( ) {
2032+ let sourceTextView = TextViewStub ( withHTML: " <p>This is text with attributes: <strong>bold</strong> and <italic>italic</italic></p> " )
2033+
2034+ sourceTextView. selectedRange = NSRange ( location: 0 , length: sourceTextView. text. count)
2035+ sourceTextView. copy ( nil )
2036+
2037+ XCTAssertEqual ( UIPasteboard . general. html ( ) , " <p>This is text with attributes: <strong>bold</strong> and <italic>italic</italic></p> " )
2038+ }
2039+
2040+ func testCutHTML( ) {
2041+ let sourceTextView = TextViewStub ( withHTML: " <p>This is text with attributes: <strong>bold</strong> and <italic>italic</italic></p> " )
2042+
2043+ sourceTextView. selectedRange = NSRange ( location: 0 , length: sourceTextView. text. count)
2044+ sourceTextView. cut ( nil )
2045+
2046+ XCTAssertEqual ( UIPasteboard . general. html ( ) , " <p>This is text with attributes: <strong>bold</strong> and <italic>italic</italic></p> " )
2047+ }
2048+
2049+ func testCopyPartialHTML( ) {
2050+ let sourceTextView = TextViewStub ( withHTML: " <p><strong>bold</strong> and <italic>italic</italic></p> " )
2051+
2052+ sourceTextView. selectedRange = NSRange ( location: 0 , length: 3 )
2053+ sourceTextView. copy ( nil )
2054+
2055+ XCTAssertEqual ( UIPasteboard . general. html ( ) , " <p><strong>bol</strong></p> " )
2056+ }
2057+
20302058}
0 commit comments