diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:18 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:29 +0100 |
commit | 04f2f864e270e772c6326cefdf24947f0130e492 (patch) | |
tree | 46f83f909b888a66c741032ab955afc6eab84292 /test/functional/plugin/lsp/utils_spec.lua | |
parent | 59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff) | |
download | rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2 rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip |
refactor: format test/*
Diffstat (limited to 'test/functional/plugin/lsp/utils_spec.lua')
-rw-r--r-- | test/functional/plugin/lsp/utils_spec.lua | 117 |
1 files changed, 61 insertions, 56 deletions
diff --git a/test/functional/plugin/lsp/utils_spec.lua b/test/functional/plugin/lsp/utils_spec.lua index 804dc32f0d..bb9cdb8390 100644 --- a/test/functional/plugin/lsp/utils_spec.lua +++ b/test/functional/plugin/lsp/utils_spec.lua @@ -10,7 +10,8 @@ describe('vim.lsp.util', function() describe('stylize_markdown', function() local stylize_markdown = function(content, opts) - return exec_lua([[ + return exec_lua( + [[ local bufnr = vim.uri_to_bufnr("file:///fake/uri") vim.fn.bufload(bufnr) @@ -20,14 +21,17 @@ describe('vim.lsp.util', function() local stripped_content = vim.lsp.util.stylize_markdown(bufnr, content, opts) return stripped_content - ]], content, opts) + ]], + content, + opts + ) end it('code fences', function() local lines = { - "```lua", + '```lua', "local hello = 'world'", - "```", + '```', } local expected = { "local hello = 'world'", @@ -38,9 +42,9 @@ describe('vim.lsp.util', function() it('code fences with whitespace surrounded info string', function() local lines = { - "``` lua ", + '``` lua ', "local hello = 'world'", - "```", + '```', } local expected = { "local hello = 'world'", @@ -51,16 +55,16 @@ describe('vim.lsp.util', function() it('adds separator after code block', function() local lines = { - "```lua", + '```lua', "local hello = 'world'", - "```", - "", - "something", + '```', + '', + 'something', } local expected = { "local hello = 'world'", - "─────────────────────", - "something", + '─────────────────────', + 'something', } local opts = { separator = true } eq(expected, stylize_markdown(lines, opts)) @@ -68,28 +72,28 @@ describe('vim.lsp.util', function() it('replaces supported HTML entities', function() local lines = { - "1 < 2", - "3 > 2", - ""quoted"", - "'apos'", - "   ", - "&", + '1 < 2', + '3 > 2', + '"quoted"', + ''apos'', + '   ', + '&', } local expected = { - "1 < 2", - "3 > 2", + '1 < 2', + '3 > 2', '"quoted"', "'apos'", - " ", - "&", + ' ', + '&', } local opts = {} eq(expected, stylize_markdown(lines, opts)) end) end) - describe('normalize_markdown', function () - it('collapses consecutive blank lines', function () + describe('normalize_markdown', function() + it('collapses consecutive blank lines', function() local result = exec_lua [[ local lines = { 'foo', @@ -102,11 +106,11 @@ describe('vim.lsp.util', function() } return vim.lsp.util._normalize_markdown(lines) ]] - local expected = {'foo', '', 'bar', '', 'baz'} + local expected = { 'foo', '', 'bar', '', 'baz' } eq(expected, result) end) - it('removes preceding and trailing empty lines', function () + it('removes preceding and trailing empty lines', function() local result = exec_lua [[ local lines = { '', @@ -117,103 +121,105 @@ describe('vim.lsp.util', function() } return vim.lsp.util._normalize_markdown(lines) ]] - local expected = {'foo', 'bar'} + local expected = { 'foo', 'bar' } eq(expected, result) end) end) - describe("make_floating_popup_options", function () - + describe('make_floating_popup_options', function() local function assert_anchor(anchor_bias, expected_anchor) - local opts = exec_lua([[ + local opts = exec_lua( + [[ local args = { ... } local anchor_bias = args[1] return vim.lsp.util.make_floating_popup_options(30, 10, { anchor_bias = anchor_bias }) - ]], anchor_bias) + ]], + anchor_bias + ) - eq(expected_anchor, string.sub(opts.anchor, 1, 1)) + eq(expected_anchor, string.sub(opts.anchor, 1, 1)) end local screen - before_each(function () + before_each(function() helpers.clear() screen = Screen.new(80, 80) screen:attach() - feed("79i<CR><Esc>") -- fill screen with empty lines + feed('79i<CR><Esc>') -- fill screen with empty lines end) - describe('when on the first line it places window below', function () - before_each(function () + describe('when on the first line it places window below', function() + before_each(function() feed('gg') end) - it('for anchor_bias = "auto"', function () + it('for anchor_bias = "auto"', function() assert_anchor('auto', 'N') end) - it('for anchor_bias = "above"', function () + it('for anchor_bias = "above"', function() assert_anchor('above', 'N') end) - it('for anchor_bias = "below"', function () + it('for anchor_bias = "below"', function() assert_anchor('below', 'N') end) end) - describe('when on the last line it places window above', function () - before_each(function () + describe('when on the last line it places window above', function() + before_each(function() feed('G') end) - it('for anchor_bias = "auto"', function () + it('for anchor_bias = "auto"', function() assert_anchor('auto', 'S') end) - it('for anchor_bias = "above"', function () + it('for anchor_bias = "above"', function() assert_anchor('above', 'S') end) - it('for anchor_bias = "below"', function () + it('for anchor_bias = "below"', function() assert_anchor('below', 'S') end) end) - describe('with 20 lines above, 59 lines below', function () - before_each(function () + describe('with 20 lines above, 59 lines below', function() + before_each(function() feed('gg20j') end) - it('places window below for anchor_bias = "auto"', function () + it('places window below for anchor_bias = "auto"', function() assert_anchor('auto', 'N') end) - it('places window above for anchor_bias = "above"', function () + it('places window above for anchor_bias = "above"', function() assert_anchor('above', 'S') end) - it('places window below for anchor_bias = "below"', function () + it('places window below for anchor_bias = "below"', function() assert_anchor('below', 'N') end) end) - describe('with 59 lines above, 20 lines below', function () - before_each(function () + describe('with 59 lines above, 20 lines below', function() + before_each(function() feed('G20k') end) - it('places window above for anchor_bias = "auto"', function () + it('places window above for anchor_bias = "auto"', function() assert_anchor('auto', 'S') end) - it('places window above for anchor_bias = "above"', function () + it('places window above for anchor_bias = "above"', function() assert_anchor('above', 'S') end) - it('places window below for anchor_bias = "below"', function () + it('places window below for anchor_bias = "below"', function() assert_anchor('below', 'N') end) - it('bordered window truncates dimensions correctly', function () + it('bordered window truncates dimensions correctly', function() local opts = exec_lua([[ return vim.lsp.util.make_floating_popup_options(100, 100, { border = 'single' }) ]]) @@ -222,5 +228,4 @@ describe('vim.lsp.util', function() end) end) end) - end) |