Tests/OrgEditorAppKitTests/FindTests.swift

0cfdac07f7253b4bc92725e377a834511f786697
orgstar/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}
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form