aboutsummaryrefslogtreecommitdiffstats
path: root/tests/setup/automatic_installation_spec.lua
blob: ed35a63a0fb3be5d70a4c1101fabb42389bcfcdb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local spy = require "luassert.spy"
local lspconfig = require "lspconfig"
local configs = require "lspconfig.configs"
local servers = require "nvim-lsp-installer.servers"

describe("automatic_installation", function()
    it(
        "should install servers set up via lspconfig",
        async_test(function()
            local server1_installer_spy = spy.new()
            local server2_installer_spy = spy.new()
            local server1 = ServerGenerator {
                name = "automatic_installation1",
                installer = function()
                    server1_installer_spy()
                end,
            }
            local server2 = ServerGenerator {
                name = "automatic_installation2",
                installer = function()
                    server2_installer_spy()
                end,
            }

            servers.register(server1)
            servers.register(server2)

            configs[server1.name] = { default_config = {} }
            configs[server2.name] = { default_config = {} }

            require("nvim-lsp-installer").setup {
                automatic_installation = true,
            }

            lspconfig[server1.name].setup {}

            assert.wait_for(function()
                assert.spy(server1_installer_spy).was_called(1)
                assert.spy(server2_installer_spy).was_called(0)
            end)
        end)
    )
end)