@@ -30,7 +30,7 @@ describe("Tool: get_diagnostics", function()
30
30
_G .vim .api .nvim_buf_get_name = spy .new (function (bufnr )
31
31
return " /path/to/file_for_buf_" .. tostring (bufnr ) .. " .lua"
32
32
end )
33
- _G .vim .fn . json_encode = spy .new (function (obj )
33
+ _G .vim .json . encode = spy .new (function (obj )
34
34
return vim .inspect (obj ) -- Use vim.inspect as a simple serialization
35
35
end )
36
36
_G .vim .fn .bufnr = spy .new (function (filepath )
@@ -47,7 +47,7 @@ describe("Tool: get_diagnostics", function()
47
47
package.loaded [" claudecode.logger" ] = nil
48
48
_G .vim .diagnostic .get = nil
49
49
_G .vim .api .nvim_buf_get_name = nil
50
- _G .vim .fn . json_encode = nil
50
+ _G .vim .json . encode = nil
51
51
_G .vim .fn .bufnr = nil
52
52
-- Note: We don't nullify _G.vim.lsp or _G.vim.diagnostic entirely
53
53
-- as they are checked for existence.
@@ -59,7 +59,7 @@ describe("Tool: get_diagnostics", function()
59
59
expect (result ).to_be_table ()
60
60
expect (result .content ).to_be_table ()
61
61
expect (# result .content ).to_be (0 )
62
- assert .spy (_G .vim .diagnostic .get ).was_called_with ()
62
+ assert .spy (_G .vim .diagnostic .get ).was_called_with (nil )
63
63
end )
64
64
65
65
it (" should return formatted diagnostics if available" , function ()
@@ -81,10 +81,10 @@ describe("Tool: get_diagnostics", function()
81
81
expect (result .content [2 ].type ).to_be (" text" )
82
82
83
83
-- Verify JSON encoding was called with correct structure
84
- assert .spy (_G .vim .fn . json_encode ).was_called (2 )
84
+ assert .spy (_G .vim .json . encode ).was_called (2 )
85
85
86
86
-- Check the first diagnostic was encoded with 1-indexed values
87
- local first_call_args = _G .vim .fn . json_encode .calls [1 ].vals [1 ]
87
+ local first_call_args = _G .vim .json . encode .calls [1 ].vals [1 ]
88
88
expect (first_call_args .filePath ).to_be (" /path/to/file_for_buf_1.lua" )
89
89
expect (first_call_args .line ).to_be (11 ) -- 10 + 1 for 1-indexing
90
90
expect (first_call_args .character ).to_be (6 ) -- 5 + 1 for 1-indexing
@@ -119,8 +119,8 @@ describe("Tool: get_diagnostics", function()
119
119
expect (# result .content ).to_be (1 )
120
120
121
121
-- Verify only the diagnostic with a file path was included
122
- assert .spy (_G .vim .fn . json_encode ).was_called (1 )
123
- local encoded_args = _G .vim .fn . json_encode .calls [1 ].vals [1 ]
122
+ assert .spy (_G .vim .json . encode ).was_called (1 )
123
+ local encoded_args = _G .vim .json . encode .calls [1 ].vals [1 ]
124
124
expect (encoded_args .filePath ).to_be (" /path/to/file1.lua" )
125
125
end )
126
126
0 commit comments