Skip to content

Commit a9f134e

Browse files
committed
Fix Fialing Test
1 parent 3bd9c71 commit a9f134e

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

Tests/CodeEditSourceEditorTests/TextViewControllerTests.swift renamed to Tests/CodeEditSourceEditorTests/Controller/TextViewControllerTests.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,13 @@ final class TextViewControllerTests: XCTestCase {
162162
controller.findViewController?.showFindPanel(animated: false)
163163

164164
// Extra insets do not effect find panel's insets
165+
let findModel = try XCTUnwrap(controller.findViewController)
165166
try assertInsetsEqual(
166167
scrollView.contentInsets,
167-
NSEdgeInsets(top: 10 + FindPanel.height, left: 0, bottom: 10, right: 0)
168+
NSEdgeInsets(top: 10 + findModel.viewModel.panelHeight, left: 0, bottom: 10, right: 0)
168169
)
169170
XCTAssertEqual(controller.findViewController?.findPanelVerticalConstraint.constant, 0)
170-
XCTAssertEqual(controller.gutterView.frame.origin.y, -10 - FindPanel.height)
171+
XCTAssertEqual(controller.gutterView.frame.origin.y, -10 - findModel.viewModel.panelHeight)
171172
}
172173

173174
func test_editorOverScroll_ZeroCondition() throws {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// FindPanelViewModelTests.swift
3+
// CodeEditSourceEditor
4+
//
5+
// Created by Khan Winter on 4/25/25.
6+
//
7+
8+
import Testing
9+
import AppKit
10+
import CodeEditTextView
11+
@testable import CodeEditSourceEditor
12+
13+
@MainActor
14+
struct FindPanelViewModelTests {
15+
class MockPanelTarget: FindPanelTarget {
16+
var emphasisManager: EmphasisManager?
17+
var text: String = ""
18+
var findPanelTargetView: NSView
19+
var cursorPositions: [CursorPosition] = []
20+
21+
@MainActor init() {
22+
findPanelTargetView = NSView()
23+
}
24+
25+
func setCursorPositions(_ positions: [CursorPosition], scrollToVisible: Bool) { }
26+
func updateCursorPosition() { }
27+
func findPanelWillShow(panelHeight: CGFloat) { }
28+
func findPanelWillHide(panelHeight: CGFloat) { }
29+
func findPanelModeDidChange(to mode: FindPanelMode) { }
30+
}
31+
32+
@Test func viewModelHeightUpdates() async throws {
33+
let model = FindPanelViewModel(target: MockPanelTarget())
34+
model.mode = .find
35+
#expect(model.panelHeight == 28)
36+
37+
model.mode = .replace
38+
#expect(model.panelHeight == 54)
39+
}
40+
}

0 commit comments

Comments
 (0)