@@ -6,24 +6,23 @@ describe('LSP client API', function()
66 root_dir = vim .fn .tempname (),
77 },
88 }
9+ local notify_once = stub (vim , ' notify_once' )
10+ local notify = stub (vim , ' notify' )
11+ local deprecate = stub (vim , ' deprecate' )
912 -- load RustAnalyzer command
1013 require (' rustaceanvim.lsp' )
1114 local RustaceanConfig = require (' rustaceanvim.config.internal' )
1215 local Types = require (' rustaceanvim.types.internal' )
1316 local ra_bin = Types .evaluate (RustaceanConfig .server .cmd )[1 ]
1417 if vim .fn .executable (ra_bin ) == 1 then
15- it (' Can spin up rust-analyzer.' , function ()
18+ it (' can spin up rust-analyzer.' , function ()
1619 local lsp_start = stub (vim .lsp , ' start' )
17- local notify_once = stub (vim , ' notify_once' )
18- local notify = stub (vim , ' notify' )
1920 local bufnr = vim .api .nvim_create_buf (true , false )
2021 vim .api .nvim_buf_set_name (bufnr , ' test.rs' )
2122 vim .bo [bufnr ].filetype = ' rust'
2223 vim .api .nvim_set_current_buf (bufnr )
2324 vim .cmd .RustAnalyzer (' start' )
2425 assert .stub (lsp_start ).called (1 )
25- assert .stub (notify_once ).called (0 )
26- assert .stub (notify ).called (0 )
2726 -- FIXME: This might not work in a sandboxed nix build
2827 -- local ra = require('rustaceanvim.rust_analyzer')
2928 -- assert(
@@ -33,5 +32,21 @@ describe('LSP client API', function()
3332 -- 'Failed to start the rust-analyzer LSP client'
3433 -- )
3534 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 )
3651 end
3752end )
0 commit comments