Skip to content

Commit

Permalink
tests: remove deprecated handler usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mochaaP committed Dec 1, 2024
1 parent 8fd7b29 commit 02d1ad4
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions test/spec/e2e_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ describe("e2e", function()
tu.edit_test_file("test-file.txt")
end)
after_each(function()
require("null-ls.client").get_client().handlers[methods.lsp.CODE_ACTION] = nil
require("null-ls.client").get_client().handlers[methods.lsp.FORMATTING] = nil
end)

it("should use client handler", function()
Expand All @@ -612,29 +612,32 @@ describe("e2e", function()
end)
end)

describe("hover", function()
local mock_handler = require("luassert.stub").new()
-- https://github.com/neovim/neovim/commit/8260e4860b27a54a061bd8e2a9da23069993953a
-- hover no longer supports handler
if not vim.fn.has("nvim-0.11") == 1 then
describe("hover", function()
local mock_handler = require("luassert.stub").new()

before_each(function()
sources.register(builtins._test.mock_hover)
tu.edit_test_file("test-file.txt")
tu.wait()
before_each(function()
local client = require("null-ls.client").get_client()
client.handlers[methods.lsp.HOVER] = mock_handler

local client = require("null-ls.client").get_client()
client.handlers[methods.lsp.HOVER] = mock_handler
end)
after_each(function()
require("null-ls.client").get_client().handlers[methods.lsp.HOVER] = nil
end)
sources.register(builtins._test.mock_hover)
tu.edit_test_file("test-file.txt")
end)
after_each(function()
require("null-ls.client").get_client().handlers[methods.lsp.HOVER] = nil
end)

it("should call handler with results", function()
vim.lsp.buf.hover()
tu.wait()
it("should call handler with results", function()
lsp.buf.hover()
tu.wait()

assert.stub(mock_handler).was_called()
assert.same(mock_handler.calls[1].refs[2], { contents = { { "test" } } })
assert.stub(mock_handler).was_called()
assert.same(mock_handler.calls[1].refs[2], { contents = { { "test" } } })
end)
end)
end)
end

describe("client", function()
it("should not leave pending requests on client object", function()
Expand Down

0 comments on commit 02d1ad4

Please sign in to comment.