Skip to content

Commit 1448d2c

Browse files
committed
test(extra): test that pickers work without set up 'mini.pick'
1 parent 509c63b commit 1448d2c

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

tests/test_extra.lua

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ T['pickers'] = new_set({
745745
},
746746
})
747747

748+
local validate_active_picker = function() eq(child.lua_get('require("mini.pick").get_picker_state() ~= nil'), true) end
749+
748750
local validate_global_source_options = function(picker_start, check_preview, check_choose)
749751
child.lua([[
750752
MiniPick.config.source.preview = function(buf_id, item)
@@ -825,6 +827,11 @@ T['pickers']['buf_lines()']['works'] = function()
825827

826828
-- Should return chosen value with proper structure
827829
eq(child.lua_get('_G.return_item'), { bufnr = buffers[1], lnum = 2, text = 'buffer-1\0002\000 buffer 1' })
830+
831+
-- Should work without set up 'mini.pick'
832+
child.mini_unload('pick')
833+
pick_buf_lines()
834+
validate_active_picker()
828835
end
829836

830837
T['pickers']['buf_lines()']['respects `local_opts.scope`'] = function()
@@ -953,6 +960,11 @@ T['pickers']['commands()']['works'] = function()
953960

954961
-- Should return chosen value
955962
eq(child.lua_get('_G.return_item'), 'chdir')
963+
964+
-- Should work without set up 'mini.pick'
965+
child.mini_unload('pick')
966+
pick_commands()
967+
validate_active_picker()
956968
end
957969

958970
T['pickers']['commands()']['respects user commands'] = function()
@@ -1045,6 +1057,11 @@ T['pickers']['diagnostic()']['works'] = function()
10451057
message = 'Error 2',
10461058
text = 'E │ tests/dir-extra/mocks/diagnostic-file-1 │ Error 2',
10471059
})
1060+
1061+
-- Should work without set up 'mini.pick'
1062+
child.mini_unload('pick')
1063+
pick_diagnostic()
1064+
validate_active_picker()
10481065
end
10491066

10501067
T['pickers']['diagnostic()']['respects `local_opts.get_opts`'] = function()
@@ -1197,6 +1214,11 @@ T['pickers']['explorer()']['works'] = function()
11971214

11981215
-- Should return chosen value
11991216
eq(child.lua_get('_G.return_item'), { fs_type = 'file', path = init_dir .. '/file3', text = 'file3' })
1217+
1218+
-- Should work without set up 'mini.pick'
1219+
child.mini_unload('pick')
1220+
pick_explorer()
1221+
validate_active_picker()
12001222
end
12011223

12021224
T['pickers']['explorer()']['works with query'] = function()
@@ -1392,6 +1414,11 @@ T['pickers']['git_branches()']['works'] = function()
13921414

13931415
-- Should return chosen value
13941416
eq(child.lua_get('_G.return_item'), branch_lines[1])
1417+
1418+
-- Should work without set up 'mini.pick'
1419+
child.mini_unload('pick')
1420+
pick_git_branches()
1421+
validate_active_picker()
13951422
end
13961423

13971424
T['pickers']['git_branches()']['respects `local_opts.path`'] = function()
@@ -1535,6 +1562,11 @@ T['pickers']['git_commits()']['works'] = function()
15351562

15361563
-- Should return chosen value
15371564
eq(child.lua_get('_G.return_item'), log_lines[#log_lines])
1565+
1566+
-- Should work without set up 'mini.pick'
1567+
child.mini_unload('pick')
1568+
pick_git_commits()
1569+
validate_active_picker()
15381570
end
15391571

15401572
T['pickers']['git_commits()']['respects `local_opts.path`'] = function()
@@ -1640,6 +1672,11 @@ T['pickers']['git_files()']['works'] = function()
16401672

16411673
-- Should return chosen value
16421674
eq(child.lua_get('_G.return_item'), 'git-files/git-file-1')
1675+
1676+
-- Should work without set up 'mini.pick'
1677+
child.mini_unload('pick')
1678+
pick_git_files()
1679+
validate_active_picker()
16431680
end
16441681

16451682
T['pickers']['git_files()']['respects `local_opts.path`'] = function()
@@ -1796,6 +1833,11 @@ T['pickers']['git_hunks()']['works'] = function()
17961833
eq(return_item_keys, { 'header', 'hunk', 'lnum', 'path', 'text' })
17971834
eq(return_item.path, 'git-files/git-file-2')
17981835
eq(return_item.lnum, 12)
1836+
1837+
-- Should work without set up 'mini.pick'
1838+
child.mini_unload('pick')
1839+
pick_git_hunks()
1840+
validate_active_picker()
17991841
end
18001842

18011843
T['pickers']['git_hunks()']['respects `local_opts.n_context`'] = new_set({ parametrize = { { 0 }, { 20 } } }, {
@@ -2027,6 +2069,11 @@ T['pickers']['hipatterns()']['works'] = function()
20272069
end_col = 4,
20282070
text = 'minmax │ Buffer_3│3│1│max',
20292071
})
2072+
2073+
-- Should work without set up 'mini.pick'
2074+
child.mini_unload('pick')
2075+
pick_hipatterns()
2076+
validate_active_picker()
20302077
end
20312078

20322079
T['pickers']['hipatterns()']['respects `local_opts.scope`'] = function()
@@ -2132,6 +2179,11 @@ T['pickers']['history()']['works'] = function()
21322179
-- Should return chosen value with proper structure
21332180
type_keys('<CR>')
21342181
eq(child.lua_get('_G.return_item'), ': lua _G.n = _G.n + 2')
2182+
2183+
-- Should work without set up 'mini.pick'
2184+
child.mini_unload('pick')
2185+
pick_history()
2186+
validate_active_picker()
21352187
end
21362188

21372189
T['pickers']['history()']['works for command-line history'] = function()
@@ -2262,6 +2314,11 @@ T['pickers']['hl_groups()']['works'] = function()
22622314

22632315
-- Should return chosen value
22642316
eq(child.lua_get('_G.return_item'), 'SpellBad')
2317+
2318+
-- Should work without set up 'mini.pick'
2319+
child.mini_unload('pick')
2320+
pick_hl_groups()
2321+
validate_active_picker()
22652322
end
22662323

22672324
T['pickers']['hl_groups()']['respects non-default/linked highlight groups'] = function()
@@ -2338,6 +2395,11 @@ T['pickers']['keymaps()']['works'] = function()
23382395
maparg = ref_maparg,
23392396
text = 'n @ │ <Space>b │ <Cmd>lua _G.res = "buf"<CR>',
23402397
})
2398+
2399+
-- Should work without set up 'mini.pick'
2400+
child.mini_unload('pick')
2401+
pick_keymaps()
2402+
validate_active_picker()
23412403
end
23422404

23432405
T['pickers']['keymaps()']['can be chosen in non-Normal modes'] = function()
@@ -2900,6 +2962,11 @@ T['pickers']['marks()']['works'] = function()
29002962
local path_slash = path:gsub('\\', '/')
29012963
local ref_item = { col = 6, lnum = 1, path = path_slash, text = 'A │ ' .. path_slash .. '│1│6' }
29022964
eq(child.lua_get('_G.return_item'), ref_item)
2965+
2966+
-- Should work without set up 'mini.pick'
2967+
child.mini_unload('pick')
2968+
pick_marks()
2969+
validate_active_picker()
29032970
end
29042971

29052972
T['pickers']['marks()']['respects `local_opts.scope`'] = function()
@@ -2973,6 +3040,11 @@ T['pickers']['oldfiles()']['works'] = function()
29733040
--stylua: ignore
29743041
-- Should return chosen value with proper structure
29753042
eq(child.lua_get('_G.return_item'), path_1_slash)
3043+
3044+
-- Should work without set up 'mini.pick'
3045+
child.mini_unload('pick')
3046+
pick_oldfiles()
3047+
validate_active_picker()
29763048
end
29773049

29783050
T['pickers']['oldfiles()']['works with empty `v:oldfiles`'] = function()
@@ -3068,6 +3140,11 @@ T['pickers']['options()']['works'] = function()
30683140

30693141
-- Should return chosen value
30703142
eq(child.lua_get('_G.return_item'), { text = 'cursorbind', info = child.api.nvim_get_option_info('cursorbind') })
3143+
3144+
-- Should work without set up 'mini.pick'
3145+
child.mini_unload('pick')
3146+
pick_options()
3147+
validate_active_picker()
30713148
end
30723149

30733150
T['pickers']['options()']['respects set options'] = function()
@@ -3192,6 +3269,11 @@ T['pickers']['registers()']['works'] = function()
31923269

31933270
-- Should return chosen value
31943271
eq(child.lua_get('_G.return_item'), { regname = 'a', regcontents = 'Register a', text = 'a │ Register a' })
3272+
3273+
-- Should work without set up 'mini.pick'
3274+
child.mini_unload('pick')
3275+
pick_registers()
3276+
validate_active_picker()
31953277
end
31963278

31973279
T['pickers']['registers()']['can be chosen in non-Normal modes'] = function()
@@ -3301,6 +3383,11 @@ T['pickers']['spellsuggest()']['works'] = function()
33013383

33023384
-- Should return chosen value
33033385
eq(child.lua_get('_G.return_item'), { index = 1, text = 'world' })
3386+
3387+
-- Should work without set up 'mini.pick'
3388+
child.mini_unload('pick')
3389+
pick_spellsuggest()
3390+
validate_active_picker()
33043391
end
33053392

33063393
T['pickers']['spellsuggest()']['respects `local_opts.n_suggestions`'] = function()
@@ -3370,6 +3457,11 @@ T['pickers']['treesitter()']['works'] = function()
33703457
lnum = 1,
33713458
text = ' assignment_statement (1│7 - 1│12)',
33723459
})
3460+
3461+
-- Should work without set up 'mini.pick'
3462+
child.mini_unload('pick')
3463+
pick_treesitter()
3464+
validate_active_picker()
33733465
end
33743466

33753467
T['pickers']['treesitter()']['checks for active tree-sitter'] = function()
@@ -3430,6 +3522,11 @@ T['pickers']['visit_paths()']['works'] = function()
34303522

34313523
-- Should return chosen value
34323524
eq(child.lua_get('_G.return_item'), 'real-files/a.lua')
3525+
3526+
-- Should work without set up 'mini.pick'
3527+
child.mini_unload('pick')
3528+
pick_visit_paths()
3529+
validate_active_picker()
34333530
end
34343531

34353532
T['pickers']['visit_paths()']['respects `local_opts.cwd`'] = function()
@@ -3529,6 +3626,11 @@ T['pickers']['visit_labels()']['works'] = function()
35293626

35303627
-- Should return chosen path
35313628
eq(child.lua_get('_G.return_item'), 'real-files/a.lua')
3629+
3630+
-- Should work without set up 'mini.pick'
3631+
child.mini_unload('pick')
3632+
pick_visit_labels()
3633+
validate_active_picker()
35323634
end
35333635

35343636
T['pickers']['visit_labels()']['respects `local_opts.cwd`'] = function()

0 commit comments

Comments
 (0)