summaryrefslogtreecommitdiff
path: root/lua/tests/automated/entry_display_spec.lua
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2021-07-23 17:42:37 +0200
committerGitHub <noreply@github.com>2021-07-23 11:42:37 -0400
commit79644ab67731c7ba956c354bf0545282f34e10cc (patch)
treee65dbf73b3442ab1aa9fc59fc56a35b4c9edf1e0 /lua/tests/automated/entry_display_spec.lua
parent664690029fdb302bee8d3f27a458383e8477add7 (diff)
chore: use stylua for formatting (#1040)
* chore: stylua job and config * reformat with stylua
Diffstat (limited to 'lua/tests/automated/entry_display_spec.lua')
-rw-r--r--lua/tests/automated/entry_display_spec.lua46
1 files changed, 24 insertions, 22 deletions
diff --git a/lua/tests/automated/entry_display_spec.lua b/lua/tests/automated/entry_display_spec.lua
index fff78cd..a09ccae 100644
--- a/lua/tests/automated/entry_display_spec.lua
+++ b/lua/tests/automated/entry_display_spec.lua
@@ -1,30 +1,32 @@
-local entry_display = require('telescope.pickers.entry_display')
+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 = '…'}},
+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])
+ 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])
- )
+ assert.are.same(case.expected[ambiwidth], entry_display.truncate(case.args[1], case.args[2]))
vim.o.ambiwidth = original
end)
end