refactor(test): make helper test function more ergonomic

In my opinion, requiring user to access tests via `T["module_name"]`
was too fragile and typos prone.
This commit is contained in:
Olexandr Smirnov 2025-08-27 21:45:05 +03:00
parent 53ab4274c2
commit e90f766ea3
No known key found for this signature in database
8 changed files with 40 additions and 38 deletions

View file

@ -6,9 +6,11 @@ local testutils = {}
testutils.mininit_path = vim.fs.joinpath(base_dir, "scripts", "minimal_init.lua")
testutils.fixtures_dir = vim.fs.joinpath(base_dir, "spec/fixtures")
---@param name string
---@return MiniTest.child, table
function testutils.setup(name)
---@param mod string Module name for which to create a nested test set.
---@return MiniTest.child child nvim client.
---@return table T root test set created by `MiniTest.new_set()`.
---@return table mod_name nested set of tests in `T[mod]`.
function testutils.setup(mod)
local child = MiniTest.new_child_neovim()
local T = MiniTest.new_set {
hooks = {
@ -19,8 +21,8 @@ function testutils.setup(name)
},
}
T[name] = MiniTest.new_set {}
return child, T
T[mod] = MiniTest.new_set {}
return child, T, T[mod]
end
---@generic T