mirror of
https://github.com/zoriya/lz.n.git
synced 2026-05-31 18:13:01 +00:00
tests(handlers/keys): add integration test draft
This commit is contained in:
@@ -126,8 +126,9 @@ end
|
||||
|
||||
---@param plugin LzPlugin
|
||||
function M.add(plugin)
|
||||
-- TODO add plugin to M.pending
|
||||
for _, key in pairs(plugin.keys or {}) do
|
||||
M.pending[key.id] = M.pending[key.id] or {}
|
||||
M.pending[key.id][plugin.name] = plugin.name
|
||||
add_keys(key)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
local keys = require("lz.n.handler.keys")
|
||||
local state = require("lz.n.state")
|
||||
local loader = require("lz.n.loader")
|
||||
local spy = require("luassert.spy")
|
||||
|
||||
describe("keys", function()
|
||||
it("parses ids correctly", function()
|
||||
@@ -15,4 +18,20 @@ describe("keys", function()
|
||||
end
|
||||
end
|
||||
end)
|
||||
it("Key only loads plugin once", function()
|
||||
local lhs = "<C-h>k"
|
||||
---@type LzPlugin
|
||||
local plugin = {
|
||||
name = "foo",
|
||||
keys = { keys.parse(lhs) },
|
||||
}
|
||||
local spy_load = spy.on(loader, "_load")
|
||||
state.plugins[plugin.name] = plugin
|
||||
keys.add(plugin)
|
||||
local feed = vim.api.nvim_replace_termcodes("<Ignore>" .. lhs, true, true, true)
|
||||
vim.api.nvim_feedkeys(feed, "i", false)
|
||||
vim.api.nvim_feedkeys(feed, "i", false)
|
||||
assert.spy(spy_load).called(1)
|
||||
--
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user