Skip to content

Commit

Permalink
test: catch error "Invalid 'group':" properly
Browse files Browse the repository at this point in the history
  • Loading branch information
fabridamicelli committed Apr 26, 2024
1 parent 48c9b1d commit c7b8527
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/api_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ local check_autocmds = function(autocmds)
end
end


describe("api - exposed : ", function()
it("cronex package can be required", function()
require("cronex")
Expand Down Expand Up @@ -46,7 +45,14 @@ describe("api - exposed : ", function()
vim.cmd("CronExplainedDisable")
-- Trying to grab a non-existing group (expected behaviour as a result of CronExplainedDisable)
-- throws an error, so we just catch that one here
assert.has.errors(function() vim.api.nvim_get_autocmds({ group = g }) end, "Invalid 'group': 11")
assert.has.errors(
function()
local _, err = pcall(function() vim.api.nvim_get_autocmds({ group = g }) end)
if err ~= nil then
local msg = string.match(err, "Invalid 'group':")
error(msg)
end
end, "Invalid 'group':")

-- Re-activating plugin should make commands available again
vim.cmd("CronExplainedEnable")
Expand Down

0 comments on commit c7b8527

Please sign in to comment.