Skip to content

Commit 71b0d7a

Browse files
committed
test(commands): verify dynamic quick peek completion
1 parent 643411a commit 71b0d7a

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

tests/commands_spec.lua

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
describe("peekstack.commands", function()
22
local commands = require("peekstack.commands")
33
local config = require("peekstack.config")
4+
local peekstack = require("peekstack")
45
local persist = require("peekstack.persist")
56
local original_list_sessions = nil
67
local original_select = nil
@@ -135,15 +136,37 @@ describe("peekstack.commands", function()
135136
assert.equals("alpha: 0 items (updated: formatted-time)", prompts[2])
136137
end)
137138

138-
it("includes extended providers in quick peek completion", function()
139-
commands.setup()
139+
it("uses registered providers for quick peek completion", function()
140+
peekstack.setup({})
140141
local names = vim.fn.getcompletion("PeekstackQuickPeek ", "cmdline")
141142

142143
assert.is_true(vim.list_contains(names, "lsp.declaration"))
143144
assert.is_true(vim.list_contains(names, "lsp.symbols_document"))
144145
assert.is_true(vim.list_contains(names, "diagnostics.in_buffer"))
146+
assert.is_false(vim.list_contains(names, "marks.buffer"))
147+
assert.is_false(vim.list_contains(names, "marks.global"))
148+
assert.is_false(vim.list_contains(names, "marks.all"))
149+
end)
150+
151+
it("reflects provider registration changes in quick peek completion", function()
152+
peekstack.setup({
153+
providers = {
154+
marks = {
155+
enable = true,
156+
},
157+
},
158+
})
159+
160+
local names = vim.fn.getcompletion("PeekstackQuickPeek ", "cmdline")
145161
assert.is_true(vim.list_contains(names, "marks.buffer"))
146162
assert.is_true(vim.list_contains(names, "marks.global"))
147163
assert.is_true(vim.list_contains(names, "marks.all"))
164+
165+
peekstack.register_provider("custom.test", function(_ctx, cb)
166+
cb({})
167+
end)
168+
169+
names = vim.fn.getcompletion("PeekstackQuickPeek ", "cmdline")
170+
assert.is_true(vim.list_contains(names, "custom.test"))
148171
end)
149172
end)

0 commit comments

Comments
 (0)