1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 21:00:06 +08:00
SpaceVim/bundle/telescope.nvim-0.1.2/lua/tests/automated/entry_display_spec.lua

35 lines
1.8 KiB
Lua
Raw Normal View History

2022-05-16 22:20:10 +08:00
local entry_display = require "telescope.pickers.entry_display"
describe("truncate", function()
for _, ambiwidth in ipairs { "single", "double" } do
for _, case in ipairs {
{ args = { "abcde", 6 }, expected = { single = "abcde", double = "abcde" } },
{ args = { "abcde", 5 }, expected = { single = "abcde", double = "abcde" } },
{ args = { "abcde", 4 }, expected = { single = "abc…", double = "ab…" } },
{ args = { "アイウエオ", 11 }, expected = { single = "アイウエオ", double = "アイウエオ" } },
{ args = { "アイウエオ", 10 }, expected = { single = "アイウエオ", double = "アイウエオ" } },
{ args = { "アイウエオ", 9 }, expected = { single = "アイウエ…", double = "アイウ…" } },
{ args = { "アイウエオ", 8 }, expected = { single = "アイウ…", double = "アイウ…" } },
{ args = { "├─┤", 7 }, expected = { single = "├─┤", double = "├─┤" } },
{ args = { "├─┤", 6 }, expected = { single = "├─┤", double = "├─┤" } },
{ args = { "├─┤", 5 }, expected = { single = "├─┤", double = "├…" } },
{ args = { "├─┤", 4 }, expected = { single = "├─┤", double = "├…" } },
{ args = { "├─┤", 3 }, expected = { single = "├─┤", double = "" } },
{ args = { "├─┤", 2 }, expected = { single = "├…", double = "" } },
} do
local msg = ("can truncate: ambiwidth = %s, [%s, %d] -> %s"):format(
ambiwidth,
case.args[1],
case.args[2],
case.expected[ambiwidth]
)
it(msg, function()
local original = vim.o.ambiwidth
vim.o.ambiwidth = ambiwidth
assert.are.same(case.expected[ambiwidth], entry_display.truncate(case.args[1], case.args[2]))
vim.o.ambiwidth = original
end)
end
end
end)