Skip to content

Commit

Permalink
Added test cases for insertString and deleteString
Browse files Browse the repository at this point in the history
  • Loading branch information
kaunteya committed Mar 24, 2024
1 parent 0851013 commit 7682819
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Tests/TextViewPlusTests/TextViewPlusTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,44 @@ final class TextViewPlusTests: XCTestCase {

XCTAssertEqual(textView.string, "abc")
}

func testProgrammaticInsertionOfAttributedString() {
let textView = TestableTextView(string: "abc")

let attrString = NSAttributedString(string: "z")
textView.insertString(attrString, at: 1)

XCTAssertEqual(textView.string, "azbc")

textView.undoManager!.undo()

XCTAssertEqual(textView.string, "abc")
}

func testProgrammaticDeletionOfAttributedString() {
let textView = TestableTextView(string: "abc")

textView.deleteString(in: NSRange(location: 1, length: 1))

XCTAssertEqual(textView.string, "ac")

textView.undoManager!.undo()

XCTAssertEqual(textView.string, "abc")
}

func testProgrammaticDeletionOfAttributedStringWithFullRange() {
let textView = TestableTextView(string: "abc")

textView.deleteString(in: NSRange(location: 0, length: 3))

XCTAssert(textView.string.isEmpty)

textView.undoManager!.undo()

XCTAssertEqual(textView.string, "abc")
}

}

extension TextViewPlusTests {
Expand Down

0 comments on commit 7682819

Please sign in to comment.