* wip: 2021-07-22 15:00 BST * wip: `horizontal` refactored * wip: `center` refactored * wip: `cursor` and `vertical` refactored * wip: `current_buffer` refactor - also changed `layout_config_defaults` as they gave errors when using `current_buffer` * wip: `bottom_pane` refactor * [docgen] Update doc/telescope.txt skip-checks: true * fix: put accidentally remove config option back * [docgen] Update doc/telescope.txt skip-checks: true * wip: standardise `height` calculation for `center` and `bottom_pane` * wip: improve comments * [docgen] Update doc/telescope.txt skip-checks: true * stylua - also fix a merge mistake * [docgen] Update doc/telescope.txt skip-checks: true * fix: attempt to fix bad merge * refactor: remove unused entry in `borderchars` table - also fix some typos * wip: tweak padding for `bottom_pane` * wip: add `tabline` checks to `bottom_pane` - also tweaked position so that `statusline` is not covered when borders are enabled * stylua * refactor: factor out size capping function * [docgen] Update doc/telescope.txt skip-checks: true * fix: adjust tests that relied on height being number of results * fix: forgot variable in calc_size_and_spacing * fix: maybe this fixes these tests? * test: try other plenary branch for ci * test: switch back to main plenary branch for ci * fix: actually define `max_results` in the test * fix: final tweaks for edge cases Co-authored-by: Github Actions <actions@github>
69 lines
2.0 KiB
Lua
69 lines
2.0 KiB
Lua
local eq = function(a, b)
|
|
assert.are.same(a, b)
|
|
end
|
|
|
|
local resolve = require "telescope.config.resolve"
|
|
|
|
describe("telescope.config.resolve", function()
|
|
describe("win_option", function()
|
|
it("should resolve for percentages", function()
|
|
local height_config = 0.8
|
|
local opt = resolve.win_option(height_config)
|
|
|
|
eq(height_config, opt.preview)
|
|
eq(height_config, opt.prompt)
|
|
eq(height_config, opt.results)
|
|
end)
|
|
|
|
it("should resolve for percentages with default", function()
|
|
local height_config = 0.8
|
|
local opt = resolve.win_option(nil, height_config)
|
|
|
|
eq(height_config, opt.preview)
|
|
eq(height_config, opt.prompt)
|
|
eq(height_config, opt.results)
|
|
end)
|
|
|
|
it("should resolve table values", function()
|
|
local table_val = { "a" }
|
|
local opt = resolve.win_option(nil, table_val)
|
|
|
|
eq(table_val, opt.preview)
|
|
eq(table_val, opt.prompt)
|
|
eq(table_val, opt.results)
|
|
end)
|
|
|
|
it("should allow overrides for different wins", function()
|
|
local prompt_override = { "a", prompt = "b" }
|
|
local opt = resolve.win_option(prompt_override)
|
|
eq("a", opt.preview)
|
|
eq("a", opt.results)
|
|
eq("b", opt.prompt)
|
|
end)
|
|
|
|
it("should allow overrides for all wins", function()
|
|
local all_specified = { preview = "a", prompt = "b", results = "c" }
|
|
local opt = resolve.win_option(all_specified)
|
|
eq("a", opt.preview)
|
|
eq("b", opt.prompt)
|
|
eq("c", opt.results)
|
|
end)
|
|
|
|
it("should allow some specified with a simple default", function()
|
|
local some_specified = { prompt = "b", results = "c" }
|
|
local opt = resolve.win_option(some_specified, "a")
|
|
eq("a", opt.preview)
|
|
eq("b", opt.prompt)
|
|
eq("c", opt.results)
|
|
end)
|
|
end)
|
|
|
|
describe("resolve_height/width", function()
|
|
eq(10, resolve.resolve_height(0.1)(nil, 24, 100))
|
|
eq(2, resolve.resolve_width(0.1)(nil, 24, 100))
|
|
|
|
eq(10, resolve.resolve_width(10)(nil, 24, 100))
|
|
eq(24, resolve.resolve_width(50)(nil, 24, 100))
|
|
end)
|
|
end)
|