diff options
| author | kylo252 <[email protected]> | 2021-10-31 16:23:44 +0100 | 
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-31 16:23:44 +0100 | 
| commit | e8693406babee724dd51293dc6dad10931dbef45 (patch) | |
| tree | cd3abce7b226f68d34126b88378f4936384a14e2 /tests | |
| parent | 7a2a5fc810e6eaef185d9b0023b598a83c29d93e (diff) | |
perf(lsp): use the new upstream API for filetypes (#1836)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/config_loader_spec.lua | 8 | ||||
| -rw-r--r-- | tests/lsp_spec.lua | 36 | 
2 files changed, 18 insertions, 26 deletions
diff --git a/tests/config_loader_spec.lua b/tests/config_loader_spec.lua index 8e7ab339..1aef0974 100644 --- a/tests/config_loader_spec.lua +++ b/tests/config_loader_spec.lua @@ -1,5 +1,6 @@  local a = require "plenary.async_lib.tests"  local config = require "lvim.config" +local utils = require "lvim.utils"  a.describe("config-loader", function()    local user_config_path = config:get_user_config_path() @@ -20,18 +21,19 @@ a.describe("config-loader", function()      vim.opt.undodir = "/tmp"      assert.equal(vim.opt.undodir:get()[1], "/tmp")      config:reload() -    assert.equal(vim.opt.undodir:get()[1], get_cache_dir() .. "/undo") +    assert.equal(vim.opt.undodir:get()[1], utils.join_paths(get_cache_dir(), "undo"))    end)    a.it("should not get interrupted by errors in user-config", function()      vim.opt.undodir = "/tmp"      assert.equal(vim.opt.undodir:get()[1], "/tmp") -    os.execute("echo bad_string_test >> " .. user_config_path) +    os.execute(string.format("echo 'bad_string_test' >> %s", user_config_path))      local error_handler = function(msg)        return msg      end      local err = xpcall(config:reload(), error_handler)      assert.falsy(err) -    assert.equal(vim.opt.undodir:get()[1], get_cache_dir() .. "/undo") +    assert.equal(vim.opt.undodir:get()[1], utils.join_paths(get_cache_dir(), "undo")) +    os.execute(string.format("echo '' > %s", user_config_path))    end)  end) diff --git a/tests/lsp_spec.lua b/tests/lsp_spec.lua index 173810e0..b3bb59ab 100644 --- a/tests/lsp_spec.lua +++ b/tests/lsp_spec.lua @@ -44,29 +44,6 @@ a.describe("lsp workflow", function()      end)    end) -  a.it("shoud retrieve supported filetypes correctly", function() -    local ocaml = { -      name = "ocamlls", -      filetypes = { "ocaml", "reason" }, -    } -    local ocaml_fts = require("lvim.lsp.utils").get_supported_filetypes(ocaml.name) -    assert.True(vim.deep_equal(ocaml.filetypes, ocaml_fts)) - -    local tsserver = { -      name = "tsserver", -      filetypes = { -        "javascript", -        "javascriptreact", -        "javascript.jsx", -        "typescript", -        "typescriptreact", -        "typescript.tsx", -      }, -    } -    local tsserver_fts = require("lvim.lsp.utils").get_supported_filetypes(tsserver.name) -    assert.True(vim.deep_equal(tsserver.filetypes, tsserver_fts)) -  end) -    a.it("shoud not include blacklisted servers in the generated templates", function()      assert.True(utils.is_directory(lvim.lsp.templates_dir))      require("lvim.lsp").setup() @@ -77,4 +54,17 @@ a.describe("lsp workflow", function()        end      end    end) + +  a.it("shoud only include one server per generated template", function() +    assert.True(utils.is_directory(lvim.lsp.templates_dir)) +    require("lvim.lsp").setup() + +    for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do +      local count = 0 +      for _ in io.lines(file) do +        count = count + 1 +      end +      assert.equal(count, 1) +    end +  end)  end)  | 
