spacevim/bundle/telescope.nvim-0.1.5/lua/tests/automated/layout_strategies_spec.lua
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

162 lines
3.9 KiB
Lua

local config = require "telescope.config"
local resolve = require "telescope.config.resolve"
local layout_strats = require "telescope.pickers.layout_strategies"
local validate_layout_config = layout_strats._validate_layout_config
local eq = assert.are.same
describe("layout_strategies", function()
it("should have validator", function()
assert(validate_layout_config, "Has validator")
end)
local test_height = function(should, output, input, opts)
opts = opts or {}
local max_columns, max_lines = opts.max_columns or 100, opts.max_lines or 100
it(should, function()
local layout_config = validate_layout_config("horizontal", { height = true }, { height = input })
eq(output, resolve.resolve_height(layout_config.height)({}, max_columns, max_lines))
end)
end
test_height("should handle numbers", 10, 10)
test_height("should handle percentage: 100", 10, 0.1, { max_lines = 100 })
test_height("should handle percentage: 110", 11, 0.1, { max_lines = 110 })
test_height("should call functions: simple", 5, function()
return 5
end)
test_height("should call functions: percentage", 15, function(_, _, lines)
return 0.1 * lines
end, {
max_lines = 150,
})
local test_defaults_key = function(should, key, strat, output, ours, theirs, override)
ours = ours or {}
theirs = theirs or {}
override = override or {}
it(should, function()
config.clear_defaults()
config.set_defaults({ layout_config = theirs }, { layout_config = { ours, "description" } })
local layout_config = validate_layout_config(strat, layout_strats._configurations[strat], override)
eq(output, layout_config[key])
end)
end
test_defaults_key(
"should use ours if theirs and override don't give the key",
"height",
"horizontal",
50,
{ height = 50 },
{ width = 100 },
{ width = 120 }
)
test_defaults_key(
"should use ours if theirs and override don't give the key for this strategy",
"height",
"horizontal",
50,
{ height = 50 },
{ vertical = { height = 100 } },
{ vertical = { height = 120 } }
)
test_defaults_key(
"should use theirs if override doesn't give the key",
"height",
"horizontal",
100,
{ height = 50 },
{ height = 100 },
{ width = 120 }
)
test_defaults_key(
"should use override if key given",
"height",
"horizontal",
120,
{ height = 50 },
{ height = 100 },
{ height = 120 }
)
test_defaults_key(
"should use override if key given for this strategy",
"height",
"horizontal",
120,
{ height = 50 },
{ height = 100 },
{ horizontal = { height = 120 } }
)
test_defaults_key(
"should use theirs if override doesn't give key (even if ours has strategy specific)",
"height",
"horizontal",
100,
{ horizontal = { height = 50 } },
{ height = 100 },
{ width = 120 }
)
test_defaults_key(
"should use override (even if ours has strategy specific)",
"height",
"horizontal",
120,
{ horizontal = { height = 50 } },
{ height = 100 },
{ height = 120 }
)
test_defaults_key(
"should use override (even if theirs has strategy specific)",
"height",
"horizontal",
120,
{ height = 50 },
{ horizontal = { height = 100 } },
{ height = 120 }
)
test_defaults_key(
"should use override (even if ours and theirs have strategy specific)",
"height",
"horizontal",
120,
{ horizontal = { height = 50 } },
{ horizontal = { height = 100 } },
{ height = 120 }
)
test_defaults_key(
"should handle user config overriding a table with a number",
"height",
"horizontal",
120,
{ height = { padding = 5 } },
{ height = 120 },
{}
)
test_defaults_key(
"should handle user oneshot overriding a table with a number",
"height",
"horizontal",
120,
{},
{ height = { padding = 5 } },
{ height = 120 }
)
end)