Skip to content

Commit fc2af03

Browse files
committed
tests: fix plenary after_each inconsistency (closes #1)
1 parent a008d53 commit fc2af03

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

test/minimal_init.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ end
99
function M.load(plugin)
1010
local name = plugin:match(".*/(.*)")
1111
local package_root = M.root(".tests/site/pack/deps/start/")
12-
if not vim.uv.fs_stat(package_root .. name) then
12+
local uv = vim.uv or vim.loop
13+
if not uv.fs_stat(package_root .. name) then
1314
print("Installing " .. plugin)
1415
vim.fn.mkdir(package_root, "p")
1516
vim.fn.system({

test/spec/diagnostics_spec.lua

+13
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,19 @@ describe("diagnostics", function()
113113
assert.stub(diagnostic_api.set).was_called(2)
114114
end)
115115

116+
it("should call handler only once if buffer changed in between callbacks", function()
117+
diagnostics.handler(mock_params)
118+
119+
local new_params = vim.deepcopy(mock_params)
120+
new_params.textDocument.version = 9999
121+
diagnostics.handler(new_params)
122+
123+
generators.run_registered.calls[2].refs[1].after_each(mock_diagnostics, new_params, mock_generator)
124+
generators.run_registered.calls[1].refs[1].after_each(mock_diagnostics, mock_params, mock_generator)
125+
126+
assert.stub(diagnostic_api.set).was_called(1)
127+
end)
128+
116129
it("should call handler on each callback if buffer changed but method is different", function()
117130
diagnostics.handler(mock_params)
118131
generators.run_registered.calls[1].refs[1].after_each(mock_diagnostics, mock_params, mock_generator)

0 commit comments

Comments
 (0)