aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ui_status_win_spec.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-12-25 21:47:57 +0100
committerGitHub <noreply@github.com>2021-12-25 21:47:57 +0100
commit5957e7a29005c286eaf2cc619e826cfd980eb5ff (patch)
tree8fb998c67cdb195ad68813498cace7ef64044a8c /tests/ui_status_win_spec.lua
parentfix(zls): add chmod +x to binary (#362) (diff)
downloadmason-5957e7a29005c286eaf2cc619e826cfd980eb5ff.tar
mason-5957e7a29005c286eaf2cc619e826cfd980eb5ff.tar.gz
mason-5957e7a29005c286eaf2cc619e826cfd980eb5ff.tar.bz2
mason-5957e7a29005c286eaf2cc619e826cfd980eb5ff.tar.lz
mason-5957e7a29005c286eaf2cc619e826cfd980eb5ff.tar.xz
mason-5957e7a29005c286eaf2cc619e826cfd980eb5ff.tar.zst
mason-5957e7a29005c286eaf2cc619e826cfd980eb5ff.zip
feat(ui): sort servers alphabetically, also add language hints (#361)
Diffstat (limited to 'tests/ui_status_win_spec.lua')
-rw-r--r--tests/ui_status_win_spec.lua49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/ui_status_win_spec.lua b/tests/ui_status_win_spec.lua
new file mode 100644
index 00000000..01f06c3a
--- /dev/null
+++ b/tests/ui_status_win_spec.lua
@@ -0,0 +1,49 @@
+local ServerHints = require "nvim-lsp-installer.ui.status-win.server_hints"
+
+describe("status win server hints", function()
+ it("should produce valid server hints", function()
+ local srv = ServerGenerator {
+ name = "rust_analyzer",
+ languages = { "rust", "analyz", "totallynotjavascript" },
+ }
+ local hints = ServerHints.new(srv)
+ assert.equal(vim.inspect { "analyz", "totallynotjavascript" }, vim.inspect(hints:get_hints()))
+ assert.equal("(analyz, totallynotjavascript)", tostring(hints))
+ end)
+
+ it("should not produce server hints", function()
+ local srv = ServerGenerator {
+ name = "rust_analyzer",
+ languages = { "rust" },
+ }
+ local srv2 = ServerGenerator {
+ name = "cssmodules_ls",
+ languages = { "css" },
+ }
+ local hints = ServerHints.new(srv)
+ assert.equal(vim.inspect {}, vim.inspect(hints:get_hints()))
+ assert.equal("", tostring(hints))
+
+ local hints2 = ServerHints.new(srv2)
+ assert.equal(vim.inspect {}, vim.inspect(hints2:get_hints()))
+ assert.equal("", tostring(hints2))
+ end)
+
+ it("should produce server hints even when there's a match if language is short or long", function()
+ local srv = ServerGenerator {
+ name = "clangd",
+ languages = { "c", "c++" },
+ }
+ local srv2 = ServerGenerator {
+ name = "this_is_a_very_cool_rust_server",
+ languages = { "rust" },
+ }
+ local hints = ServerHints.new(srv)
+ assert.equal(vim.inspect { "c", "c++" }, vim.inspect(hints:get_hints()))
+ assert.equal("(c, c++)", tostring(hints))
+
+ local hints2 = ServerHints.new(srv2)
+ assert.equal(vim.inspect { "rust" }, vim.inspect(hints2:get_hints()))
+ assert.equal("(rust)", tostring(hints2))
+ end)
+end)