Skip to content

Commit

Permalink
test: remove deprecated usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mochaaP committed Dec 1, 2024
1 parent d950703 commit 8fd7b29
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions test/spec/client_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ describe("client", function()
local supports_method
before_each(function()
on_init(mock_client)
supports_method = mock_client.supports_method
if vim.fn.has("nvim-0.11") == 1 then
supports_method = function(method)
return mock_client:supports_method(method)
end
else
supports_method = mock_client.supports_method
end
end)
after_each(function()
can_run.returns(nil)
Expand Down Expand Up @@ -254,23 +260,23 @@ describe("client", function()
it("should not attach if buftype is not empty", function()
api.nvim_get_option_value.returns("nofile")

client.try_add(mock_bufnr, function()
client.try_add(mock_bufnr, function(did_attach)
assert.falsy(did_attach)
end)
end)

it("should not attach if name is empty", function()
api.nvim_buf_get_name.returns("")

client.try_add(mock_bufnr, function()
client.try_add(mock_bufnr, function(did_attach)
assert.falsy(did_attach)
end)
end)

it("should not attach if no source is available", function()
sources.is_available.returns(false)

client.try_add(mock_bufnr, function()
client.try_add(mock_bufnr, function(did_attach)
assert.falsy(did_attach)
end)
end)
Expand Down Expand Up @@ -330,7 +336,11 @@ describe("client", function()

client.notify_client(mock_method, mock_params)

assert.stub(notify).was_called_with(mock_method, mock_params)
if vim.fn.has("nvim-0.11") == 1 then
assert.stub(notify).was_called_with(mock_client, mock_method, mock_params)
else
assert.stub(notify).was_called_with(mock_method, mock_params)
end
end)
end)

Expand Down
4 changes: 2 additions & 2 deletions test/spec/utils/utils_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe("utils", function()
end)

it("should not add final newline to table when eol option is false", function()
vim.api.nvim_buf_set_option(vim.api.nvim_get_current_buf(), "eol", false)
vim.api.nvim_set_option_value("eol", false, { buf = vim.api.nvim_get_current_buf() })
local content = u.buf.content()

assert.same(content, { 'print("I am a test file!")' })
Expand All @@ -284,7 +284,7 @@ describe("utils", function()
end)

it("should not add final newline to string when eol option is false", function()
vim.api.nvim_buf_set_option(vim.api.nvim_get_current_buf(), "eol", false)
vim.api.nvim_set_option_value("eol", false, { buf = vim.api.nvim_get_current_buf() })
local content = u.buf.content(nil, true)

assert.equals(content, 'print("I am a test file!")')
Expand Down

0 comments on commit 8fd7b29

Please sign in to comment.