gopher.nvim/spec/integration/comment_test.lua
Olexandr Smirnov e90f766ea3
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.
2025-08-27 22:00:52 +03:00

37 lines
867 B
Lua

local t = require "spec.testutils"
local child, T, comment = t.setup "comment"
local function do_the_test(fixture, pos)
local rs = t.setup_test("comment/" .. fixture, child, pos)
child.cmd "GoCmt"
child.cmd "write"
t.eq(t.readfile(rs.tmp), rs.fixtures.output)
t.cleanup(rs)
end
comment["should add comment to package"] = function()
do_the_test("package", { 1, 1 })
end
comment["should add comment to struct"] = function()
do_the_test("struct", { 4, 1 })
end
comment["should add comment to function"] = function()
do_the_test("func", { 3, 1 })
end
comment["should add comment to method"] = function()
do_the_test("method", { 5, 1 })
end
comment["should add comment to interface"] = function()
do_the_test("interface", { 3, 6 })
end
comment["otherwise should add // above cursor"] = function()
do_the_test("empty", { 1, 1 })
end
return T