mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
fix(picker.config): better config merging and tests
This commit is contained in:
parent
a194bbc374
commit
9986b47707
5 changed files with 99 additions and 35 deletions
46
tests/config_spec.lua
Normal file
46
tests/config_spec.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
---@module 'luassert'
|
||||
|
||||
local function d(v)
|
||||
return vim.inspect(v):gsub("%s+", " ")
|
||||
end
|
||||
|
||||
describe("config", function()
|
||||
local tests = {
|
||||
{
|
||||
{ 1, 2 },
|
||||
{ 3, 4 },
|
||||
{ 3, 4 },
|
||||
},
|
||||
{
|
||||
{ 1, 2 },
|
||||
nil,
|
||||
{ 1, 2 },
|
||||
},
|
||||
{
|
||||
{ a = 1, b = 2 },
|
||||
{ c = 3 },
|
||||
{ a = 1, b = 2, c = 3 },
|
||||
},
|
||||
{
|
||||
{ 1, 2, a = 1 },
|
||||
{ 3, 4, b = 2 },
|
||||
{ 3, 4, b = 2 },
|
||||
},
|
||||
{
|
||||
{ 3, 4, b = 2 },
|
||||
{ 1, 2 },
|
||||
{ 1, 2 },
|
||||
},
|
||||
{
|
||||
{ 1, 2, a = 1 },
|
||||
{ b = 2 },
|
||||
{ 1, 2, b = 2, a = 1 },
|
||||
},
|
||||
}
|
||||
for _, t in ipairs(tests) do
|
||||
it("merges correctly " .. d(t), function()
|
||||
local ret = Snacks.config.merge(t[1], t[2])
|
||||
assert.are.same(ret, t[3])
|
||||
end)
|
||||
end
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue