@@ -34,11 +34,26 @@ struct FindPanelTests {
3434 }
3535 }
3636
37- @Test func findPanelShowsOnCommandF( ) async throws {
38- let target = MockPanelTarget ( )
39- let viewModel = FindPanelViewModel ( target: target)
40- let viewController = FindViewController ( target: target, childView: NSView ( ) )
37+ let target = MockPanelTarget ( )
38+ let viewModel : FindPanelViewModel
39+ let viewController : FindViewController
40+
41+ init ( ) {
42+ viewController = FindViewController ( target: target, childView: NSView ( ) )
43+ viewModel = viewController. viewModel
44+ viewController. loadView ( )
45+ }
4146
47+ @Test func viewModelHeightUpdates( ) async throws {
48+ let model = FindPanelViewModel ( target: MockPanelTarget ( ) )
49+ model. mode = . find
50+ #expect( model. panelHeight == 28 )
51+
52+ model. mode = . replace
53+ #expect( model. panelHeight == 54 )
54+ }
55+
56+ @Test func findPanelShowsOnCommandF( ) async throws {
4257 // Show find panel
4358 viewController. showFindPanel ( )
4459
@@ -55,9 +70,6 @@ struct FindPanelTests {
5570 }
5671
5772 @Test func replaceFieldShowsWhenReplaceModeSelected( ) async throws {
58- let target = MockPanelTarget ( )
59- let viewModel = FindPanelViewModel ( target: target)
60-
6173 // Switch to replace mode
6274 viewModel. mode = . replace
6375
@@ -76,8 +88,7 @@ struct FindPanelTests {
7688 }
7789
7890 @Test func wrapAroundEnabled( ) async throws {
79- let target = MockPanelTarget ( text: " test1 \n test2 \n test3 " )
80- let viewModel = FindPanelViewModel ( target: target)
91+ target. textView. string = " test1 \n test2 \n test3 "
8192 viewModel. findText = " test "
8293 viewModel. wrapAround = true
8394
@@ -98,8 +109,7 @@ struct FindPanelTests {
98109 }
99110
100111 @Test func wrapAroundDisabled( ) async throws {
101- let target = MockPanelTarget ( text: " test1 \n test2 \n test3 " )
102- let viewModel = FindPanelViewModel ( target: target)
112+ target. textView. string = " test1 \n test2 \n test3 "
103113 viewModel. findText = " test "
104114 viewModel. wrapAround = false
105115
@@ -123,8 +133,7 @@ struct FindPanelTests {
123133 }
124134
125135 @Test func findMatches( ) async throws {
126- let target = MockPanelTarget ( text: " test1 \n test2 \n test3 " )
127- let viewModel = FindPanelViewModel ( target: target)
136+ target. textView. string = " test1 \n test2 \n test3 "
128137 viewModel. findText = " test "
129138
130139 viewModel. find ( )
@@ -136,8 +145,7 @@ struct FindPanelTests {
136145 }
137146
138147 @Test func noMatchesFound( ) async throws {
139- let target = MockPanelTarget ( text: " test1 \n test2 \n test3 " )
140- let viewModel = FindPanelViewModel ( target: target)
148+ target. textView. string = " test1 \n test2 \n test3 "
141149 viewModel. findText = " nonexistent "
142150
143151 viewModel. find ( )
@@ -147,8 +155,7 @@ struct FindPanelTests {
147155 }
148156
149157 @Test func matchCaseToggle( ) async throws {
150- let target = MockPanelTarget ( text: " Test1 \n test2 \n TEST3 " )
151- let viewModel = FindPanelViewModel ( target: target)
158+ target. textView. string = " Test1 \n test2 \n TEST3 "
152159
153160 // Test case-sensitive
154161 viewModel. matchCase = true
@@ -163,8 +170,7 @@ struct FindPanelTests {
163170 }
164171
165172 @Test func findMethodPickerOptions( ) async throws {
166- let target = MockPanelTarget ( text: " test1 test2 test3 " )
167- let viewModel = FindPanelViewModel ( target: target)
173+ target. textView. string = " test1 test2 test3 "
168174
169175 // Test contains
170176 viewModel. findMethod = . contains
@@ -197,8 +203,7 @@ struct FindPanelTests {
197203 }
198204
199205 @Test func findMethodPickerOptionsWithComplexText( ) async throws {
200- let target = MockPanelTarget ( text: " test1 test2 test3 \n prefix_test suffix_test \n word_test_word " )
201- let viewModel = FindPanelViewModel ( target: target)
206+ target. textView. string = " test1 test2 test3 \n prefix_test suffix_test \n word_test_word "
202207
203208 // Test contains with partial matches
204209 viewModel. findMethod = . contains
0 commit comments