@@ -6,24 +6,23 @@ describe('LSP client API', function()
6
6
root_dir = vim .fn .tempname (),
7
7
},
8
8
}
9
+ local notify_once = stub (vim , ' notify_once' )
10
+ local notify = stub (vim , ' notify' )
11
+ local deprecate = stub (vim , ' deprecate' )
9
12
-- load RustAnalyzer command
10
13
require (' rustaceanvim.lsp' )
11
14
local RustaceanConfig = require (' rustaceanvim.config.internal' )
12
15
local Types = require (' rustaceanvim.types.internal' )
13
16
local ra_bin = Types .evaluate (RustaceanConfig .server .cmd )[1 ]
14
17
if vim .fn .executable (ra_bin ) == 1 then
15
- it (' Can spin up rust-analyzer.' , function ()
18
+ it (' can spin up rust-analyzer.' , function ()
16
19
local lsp_start = stub (vim .lsp , ' start' )
17
- local notify_once = stub (vim , ' notify_once' )
18
- local notify = stub (vim , ' notify' )
19
20
local bufnr = vim .api .nvim_create_buf (true , false )
20
21
vim .api .nvim_buf_set_name (bufnr , ' test.rs' )
21
22
vim .bo [bufnr ].filetype = ' rust'
22
23
vim .api .nvim_set_current_buf (bufnr )
23
24
vim .cmd .RustAnalyzer (' start' )
24
25
assert .stub (lsp_start ).called (1 )
25
- assert .stub (notify_once ).called (0 )
26
- assert .stub (notify ).called (0 )
27
26
-- FIXME: This might not work in a sandboxed nix build
28
27
-- local ra = require('rustaceanvim.rust_analyzer')
29
28
-- assert(
@@ -33,5 +32,21 @@ describe('LSP client API', function()
33
32
-- 'Failed to start the rust-analyzer LSP client'
34
33
-- )
35
34
end )
35
+ it (" doesn't trigger notifications" , function ()
36
+ if not pcall (assert .stub (notify_once ).called , 0 ) then
37
+ -- this will fail, outputting the args
38
+ assert .stub (notify_once ).called_with (nil )
39
+ end
40
+ if not pcall (assert .stub (notify ).called , 0 ) then
41
+ -- this will fail, outputting the args
42
+ assert .stub (notify ).called_with (nil )
43
+ end
44
+ end )
45
+ it (" doesn't trigger deprecation warnings" , function ()
46
+ if not pcall (assert .stub (deprecate ).called , 0 ) then
47
+ -- this will fail, outputting the args
48
+ assert .stub (deprecate ).called_with (nil )
49
+ end
50
+ end )
36
51
end
37
52
end )
0 commit comments