mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
test(pack): simplify tests for data
field
This commit is contained in:
@@ -311,32 +311,20 @@ describe('vim.pack', function()
|
|||||||
eq(exec_lua('return #_G.event_log'), 0)
|
eq(exec_lua('return #_G.event_log'), 0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('passes data field through to opts.load', function()
|
it('passes `data` field through to `opts.load`', function()
|
||||||
eq(
|
local out = exec_lua(function()
|
||||||
2,
|
local map = {} ---@type table<string,boolean>
|
||||||
exec_lua(function()
|
local load = function(p)
|
||||||
local successes = 0
|
local name = p.spec.name ---@type string
|
||||||
|
map[name] = name == 'basic' and (p.spec.data.test == 'value') or (p.spec.data == 'value')
|
||||||
|
end
|
||||||
vim.pack.add({
|
vim.pack.add({
|
||||||
{ name = 'tabletest', src = repos_src.basic, data = { test = 'value' } },
|
{ src = repos_src.basic, data = { test = 'value' } },
|
||||||
{ name = 'stringtest', src = repos_src.basic, data = 'value' },
|
{ src = repos_src.defbranch, data = 'value' },
|
||||||
}, {
|
}, { load = load })
|
||||||
confirm = false,
|
return map
|
||||||
load = function(p)
|
|
||||||
if p.spec.name == 'tabletest' then
|
|
||||||
if p.spec.data.test == 'value' then
|
|
||||||
successes = successes + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if p.spec.name == 'stringtest' then
|
|
||||||
if p.spec.data == 'value' then
|
|
||||||
successes = successes + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
return successes
|
|
||||||
end)
|
end)
|
||||||
)
|
eq({ basic = true, defbranch = true }, out)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('asks for installation confirmation', function()
|
it('asks for installation confirmation', function()
|
||||||
@@ -1207,21 +1195,17 @@ describe('vim.pack', function()
|
|||||||
}, exec_lua('return vim.pack.get()'))
|
}, exec_lua('return vim.pack.get()'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('respects data field', function()
|
it('respects `data` field', function()
|
||||||
eq(
|
local out = exec_lua(function()
|
||||||
true,
|
vim.pack.add({
|
||||||
exec_lua(function()
|
|
||||||
vim.pack.add {
|
|
||||||
{ src = repos_src.basic, data = { test = 'value' } },
|
{ src = repos_src.basic, data = { test = 'value' } },
|
||||||
}
|
{ src = repos_src.defbranch, data = 'value' },
|
||||||
for _, p in ipairs(vim.pack.get()) do
|
})
|
||||||
if p.spec.name == 'basic' and p.spec.data.test == 'value' then
|
local plugs = vim.pack.get()
|
||||||
return true
|
---@type table<string,string>
|
||||||
end
|
return { basic = plugs[1].spec.data.test, defbranch = plugs[2].spec.data }
|
||||||
end
|
|
||||||
return false
|
|
||||||
end)
|
end)
|
||||||
)
|
eq({ basic = 'value', defbranch = 'value' }, out)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with `del()`', function()
|
it('works with `del()`', function()
|
||||||
|
Reference in New Issue
Block a user