Tests/OrgEditorAppKitTests/FindTests.swift
26 lines · 842 bytes
1import AppKit
2import OrgCore
3import Testing
4@testable import OrgEditorAppKit
5
6@MainActor
7struct FindTests {
8 @Test func replaceShowsTheFindBar() {
9 let h = Harness("* Heading\nbody\n")
10 #expect(h.textView.enclosingScrollView?.isFindBarVisible != true)
11 h.editor.run("edit.replace")
12 #expect(h.textView.enclosingScrollView?.isFindBarVisible == true)
13 }
14
15 @Test func aMatchInFoldedTextUnfoldsIt() {
16 let text = "* Heading\nhidden needle\n* Next\n"
17 let h = Harness(text)
18 h.caret(at: 0)
19 h.editor.cycleAtCaret()
20 #expect(!h.editor.foldState.folds.isEmpty)
21 let needle = (text as NSString).range(of: "needle")
22 h.textView.setSelectedRange(needle)
23 #expect(h.editor.foldState.folds.isEmpty)
24 #expect(h.textView.selectedRange() == needle)
25 }
26}