aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorkylo252 <59826753+kylo252@users.noreply.github.com>2022-08-05 13:36:32 +0200
committerGitHub <noreply@github.com>2022-08-05 13:36:32 +0200
commite48a41eb23778169c36b93504a7adfd4ef50b8dc (patch)
treebb179ad11c70f4e3aeb06db4575b6051b580e931 /tests
parentfeat: add dagger's cuelsp LSP (#27) (diff)
downloadmason-lspconfig-e48a41eb23778169c36b93504a7adfd4ef50b8dc.tar
mason-lspconfig-e48a41eb23778169c36b93504a7adfd4ef50b8dc.tar.gz
mason-lspconfig-e48a41eb23778169c36b93504a7adfd4ef50b8dc.tar.bz2
mason-lspconfig-e48a41eb23778169c36b93504a7adfd4ef50b8dc.tar.lz
mason-lspconfig-e48a41eb23778169c36b93504a7adfd4ef50b8dc.tar.xz
mason-lspconfig-e48a41eb23778169c36b93504a7adfd4ef50b8dc.tar.zst
mason-lspconfig-e48a41eb23778169c36b93504a7adfd4ef50b8dc.zip
feat: get_available_servers now accepts a filter (#25)
Co-authored-by: William Boman <william@redwill.se>
Diffstat (limited to 'tests')
-rw-r--r--tests/mason-lspconfig/api/api_spec.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/mason-lspconfig/api/api_spec.lua b/tests/mason-lspconfig/api/api_spec.lua
new file mode 100644
index 0000000..e4f398d
--- /dev/null
+++ b/tests/mason-lspconfig/api/api_spec.lua
@@ -0,0 +1,43 @@
+local mason_lspconfig = require "mason-lspconfig"
+local _ = require "mason-core.functional"
+
+describe("mason-lspconfig API", function()
+ it("should return all available servers", function()
+ local server_mappings = require "mason-lspconfig.mappings.server"
+ local available_servers = mason_lspconfig.get_available_servers()
+ assert.equal(#vim.tbl_keys(server_mappings.package_to_lspconfig), #available_servers)
+ end)
+
+ it("should return all available servers for given filetype", function()
+ assert.same(
+ { "terraformls", "tflint" },
+ _.sort_by(
+ _.identity,
+ mason_lspconfig.get_available_servers {
+ filetype = "terraform",
+ }
+ )
+ )
+ end)
+
+ it("should return all available servers for given filetypes", function()
+ assert.same(
+ { "lemminx", "taplo" },
+ _.sort_by(
+ _.identity,
+ mason_lspconfig.get_available_servers {
+ filetype = { "xml", "xsd", "xsl", "toml" },
+ }
+ )
+ )
+ end)
+
+ it("should return no servers if filetype predicate has no matches", function()
+ assert.same(
+ {},
+ mason_lspconfig.get_available_servers {
+ filetype = { "thisfiletypesimplydoesntexist" },
+ }
+ )
+ end)
+end)