@@ -150,148 +150,6 @@ describe("mini.files integration", function()
150
150
end
151
151
end )
152
152
153
- it (" should handle mini.files buffer paths in visual mode" , function ()
154
- mock_vim .fn .mode = function ()
155
- return " V" -- Visual line mode
156
- end
157
-
158
- -- Mock mini.files module that returns buffer-style paths
159
- local mock_mini_files = {
160
- get_fs_entry = function (buf_id , line )
161
- if buf_id ~= 1 then
162
- return nil
163
- end
164
-
165
- if line == 1 then
166
- return { path = " minifiles://42//Users/test/project/visual1.lua" }
167
- elseif line == 2 then
168
- return { path = " minifiles://42//Users/test/project/visual2.txt" }
169
- elseif line == 3 then
170
- return { path = " minifiles://42//Users/test/project/src" }
171
- end
172
- return nil
173
- end ,
174
- }
175
- package.loaded [" mini.files" ] = mock_mini_files
176
-
177
- local files , err = integrations ._get_mini_files_selection ()
178
-
179
- expect (err ).to_be_nil ()
180
- expect (files ).to_be_table ()
181
- expect (# files ).to_be (3 )
182
- expect (files [1 ]).to_be (" /Users/test/project/visual1.lua" )
183
- expect (files [2 ]).to_be (" /Users/test/project/visual2.txt" )
184
- expect (files [3 ]).to_be (" /Users/test/project/src" )
185
- end )
186
-
187
- it (" should get multiple files in visual mode" , function ()
188
- mock_vim .fn .mode = function ()
189
- return " V" -- Visual line mode
190
- end
191
-
192
- -- Mock mini.files module
193
- local mock_mini_files = {
194
- get_fs_entry = function (buf_id , line )
195
- -- Verify buffer ID is passed correctly
196
- if buf_id ~= 1 then
197
- return nil
198
- end
199
-
200
- if line == 1 then
201
- return { path = " /Users/test/project/file1.lua" }
202
- elseif line == 2 then
203
- return { path = " /Users/test/project/file2.lua" }
204
- elseif line == 3 then
205
- return { path = " /Users/test/project/src" }
206
- end
207
- return nil
208
- end ,
209
- }
210
- package.loaded [" mini.files" ] = mock_mini_files
211
-
212
- local files , err = integrations ._get_mini_files_selection ()
213
-
214
- expect (err ).to_be_nil ()
215
- expect (files ).to_be_table ()
216
- expect (# files ).to_be (3 )
217
- expect (files [1 ]).to_be (" /Users/test/project/file1.lua" )
218
- expect (files [2 ]).to_be (" /Users/test/project/file2.lua" )
219
- expect (files [3 ]).to_be (" /Users/test/project/src" )
220
- end )
221
-
222
- it (" should filter out invalid files in visual mode" , function ()
223
- mock_vim .fn .mode = function ()
224
- return " V" -- Visual line mode
225
- end
226
-
227
- -- Mock mini.files module
228
- local mock_mini_files = {
229
- get_fs_entry = function (buf_id , line )
230
- if line == 1 then
231
- return { path = " /Users/test/project/valid.lua" }
232
- elseif line == 2 then
233
- return { path = " /Users/test/project/invalid.xyz" } -- Won't pass filereadable/isdirectory
234
- elseif line == 3 then
235
- return { path = " /Users/test/project/src" }
236
- end
237
- return nil
238
- end ,
239
- }
240
- package.loaded [" mini.files" ] = mock_mini_files
241
-
242
- local files , err = integrations ._get_mini_files_selection ()
243
-
244
- expect (err ).to_be_nil ()
245
- expect (files ).to_be_table ()
246
- expect (# files ).to_be (2 ) -- Only valid.lua and src
247
- expect (files [1 ]).to_be (" /Users/test/project/valid.lua" )
248
- expect (files [2 ]).to_be (" /Users/test/project/src" )
249
- end )
250
-
251
- it (" should handle visual mode with buffer ID correctly" , function ()
252
- mock_vim .fn .mode = function ()
253
- return " v" -- Visual character mode
254
- end
255
-
256
- -- Mock different buffer ID to test parameter passing
257
- mock_vim .api .nvim_get_current_buf = function ()
258
- return 42 -- Different buffer ID
259
- end
260
-
261
- -- Mock mini.files module that validates buffer ID
262
- local mock_mini_files = {
263
- get_fs_entry = function (buf_id , line )
264
- -- Should receive buffer ID 42
265
- if buf_id ~= 42 then
266
- error (" Expected buffer ID 42, got " .. tostring (buf_id ))
267
- end
268
-
269
- if line == 1 then
270
- return { path = " /Users/test/project/selected1.lua" }
271
- elseif line == 2 then
272
- return { path = " /Users/test/project/selected2.txt" }
273
- elseif line == 3 then
274
- return { path = " /Users/test/project/selected3.lua" }
275
- end
276
- return nil
277
- end ,
278
- }
279
- package.loaded [" mini.files" ] = mock_mini_files
280
-
281
- local files , err = integrations ._get_mini_files_selection ()
282
-
283
- expect (err ).to_be_nil ()
284
- expect (files ).to_be_table ()
285
- expect (# files ).to_be (3 )
286
- expect (files [1 ]).to_be (" /Users/test/project/selected1.lua" )
287
- expect (files [2 ]).to_be (" /Users/test/project/selected2.txt" )
288
- expect (files [3 ]).to_be (" /Users/test/project/selected3.lua" )
289
-
290
- -- Reset buffer ID for other tests
291
- mock_vim .api .nvim_get_current_buf = function ()
292
- return 1
293
- end
294
- end )
295
153
296
154
it (" should handle empty entry under cursor" , function ()
297
155
-- Mock mini.files module
@@ -375,25 +233,6 @@ describe("mini.files integration", function()
375
233
expect (# files ).to_be (0 )
376
234
end )
377
235
378
- it (" should handle visual mode with no valid entries" , function ()
379
- mock_vim .fn .mode = function ()
380
- return " V" -- Visual line mode
381
- end
382
-
383
- -- Mock mini.files module
384
- local mock_mini_files = {
385
- get_fs_entry = function (buf_id , line )
386
- return nil -- No entries
387
- end ,
388
- }
389
- package.loaded [" mini.files" ] = mock_mini_files
390
-
391
- local files , err = integrations ._get_mini_files_selection ()
392
-
393
- expect (err ).to_be (" No file found under cursor" )
394
- expect (files ).to_be_table ()
395
- expect (# files ).to_be (0 )
396
- end )
397
236
end )
398
237
399
238
describe (" get_selected_files_from_tree" , function ()
0 commit comments