test(comment): e2e

This commit is contained in:
Oleksandr Smirnov 2025-03-19 00:24:21 +02:00
parent 9eeaab25ed
commit 387021ce0a
No known key found for this signature in database
13 changed files with 80 additions and 17 deletions

View file

@ -5,23 +5,47 @@ local T = MiniTest.new_set {
hooks = {
post_once = child.stop,
pre_case = function()
MiniTest.skip "This module should be fixed first"
child.restart { "-u", t.mininit_path }
end,
},
}
local function do_the_test(fixture, pos)
local tmp = t.tmpfile()
local fixtures = t.get_fixtures("comment/" .. fixture)
t.writefile(tmp, fixtures.input)
child.cmd("silent edit " .. tmp)
child.fn.setpos(".", { child.fn.bufnr "%", unpack(pos) })
child.cmd "GoCmt"
child.cmd "write"
t.eq(t.readfile(tmp), fixtures.output)
end
T["comment"] = MiniTest.new_set {}
T["comment"]["should add comment to package"] = function()
do_the_test("package", { 1, 1 })
end
T["comment"]["should add comment to package"] = function() end
T["comment"]["should add comment to struct"] = function()
do_the_test("struct", { 4, 1 })
end
T["comment"]["should add comment to struct"] = function() end
T["comment"]["should add comment to function"] = function()
do_the_test("func", { 3, 1 })
end
T["comment"]["should add comment to function"] = function() end
T["comment"]["should add comment to method"] = function()
do_the_test("func", { 5, 1 })
end
T["comment"]["should add comment to method"] = function() end
T["comment"]["should add comment to interface"] = function()
do_the_test("interface", { 3, 1 })
end
T["comment"]["should add comment to interface"] = function() end
T["comment"]["otherwise should add // above cursor"] = function() end
T["comment"]["otherwise should add // above cursor"] = function()
do_the_test("empty", { 1, 1 })
end
return T