Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tonisevener committed Dec 15, 2023
1 parent 7de2c81 commit 4778cd2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,14 @@ final class WKSourceEditorFormatterButtonActionTests: XCTestCase {
mediator.templateFormatter?.toggleTemplateFormatting(action: .remove, in: mediator.textView)
XCTAssertEqual(mediator.textView.attributedText.string, "One Two Three Four")
}

func testStrikethroughInsertAndRemove() throws {
let text = "One Two Three Four"
mediator.textView.attributedText = NSAttributedString(string: text)
mediator.textView.selectedRange = NSRange(location: 4, length:3)
mediator.strikethroughFormatter?.toggleStrikethroughFormatting(action: .add, in: mediator.textView)
XCTAssertEqual(mediator.textView.attributedText.string, "One <s>Two</s> Three Four")
mediator.strikethroughFormatter?.toggleStrikethroughFormatting(action: .remove, in: mediator.textView)
XCTAssertEqual(mediator.textView.attributedText.string, "One Two Three Four")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,28 @@ final class WKSourceEditorTextFrameworkMediatorTests: XCTestCase {
let selectionStates1 = mediator.selectionState(selectedDocumentRange: NSRange(location: 1, length: 0))
XCTAssertFalse(selectionStates1.isHorizontalTemplate)
}

func testStrikethroughSelectionState() throws {
let text = "Testing <s>Strikethrough</s> Testing."
mediator.textView.attributedText = NSAttributedString(string: text)

let selectionStates1 = mediator.selectionState(selectedDocumentRange: NSRange(location: 0, length: 7))
let selectionStates2 = mediator.selectionState(selectedDocumentRange: NSRange(location: 11, length: 13))
let selectionStates3 = mediator.selectionState(selectedDocumentRange: NSRange(location: 29, length: 7))
XCTAssertFalse(selectionStates1.isStrikethrough)
XCTAssertTrue(selectionStates2.isStrikethrough)
XCTAssertFalse(selectionStates3.isStrikethrough)
}

func testStrikethroughSelectionStateCursor() throws {
let text = "Testing <s>Strikethrough</s> Testing."
mediator.textView.attributedText = NSAttributedString(string: text)

let selectionStates1 = mediator.selectionState(selectedDocumentRange: NSRange(location: 3, length: 0))
let selectionStates2 = mediator.selectionState(selectedDocumentRange: NSRange(location: 17, length: 0))
let selectionStates3 = mediator.selectionState(selectedDocumentRange: NSRange(location: 33, length: 0))
XCTAssertFalse(selectionStates1.isStrikethrough)
XCTAssertTrue(selectionStates2.isStrikethrough)
XCTAssertFalse(selectionStates3.isStrikethrough)
}
}

0 comments on commit 4778cd2

Please sign in to comment.