change output format for TSamAll from short- to fullname

This commit is contained in:
2025-12-27 12:53:45 +01:00
parent a6e51f280f
commit 88aa1de902
3 changed files with 148 additions and 6 deletions

View File

@@ -316,6 +316,140 @@ describe("test-samurai output formatting", function()
vim.api.nvim_set_current_buf(bufnr)
vim.api.nvim_win_set_cursor(0, { 7, 0 })
core.run_nearest()
local out_buf = vim.api.nvim_get_current_buf()
local lines = vim.api.nvim_buf_get_lines(out_buf, 0, -1, false)
vim.fn.jobstart = orig_jobstart
local has_pass = false
local has_skip = false
local has_fail = false
local has_raw_verbose = false
for _, line in ipairs(lines) do
if line == "[ PASS ] - inner 1" then
has_pass = true
elseif line == "[ SKIP ] - inner skip" then
has_skip = true
elseif line == "[ FAIL ] - inner 2" then
has_fail = true
elseif line:match("^%s*PASS%s+") then
has_raw_verbose = true
end
end
assert.is_true(has_pass)
assert.is_true(has_skip)
assert.is_true(has_fail)
assert.is_false(has_raw_verbose)
end)
it("formats jest JSON output for TSamAll as full names", function()
local json = vim.json.encode({
testResults = {
{
assertionResults = {
{ status = "passed", title = "inner 1", fullName = "outer inner 1" },
{ status = "skipped", title = "inner skip", fullName = "outer inner skip" },
{ status = "failed", title = "inner 2", fullName = "outer inner 2" },
},
},
},
})
local orig_jobstart = vim.fn.jobstart
vim.fn.jobstart = function(_cmd, opts)
if opts and opts.on_stdout then
opts.on_stdout(1, { json }, nil)
end
if opts and opts.on_exit then
opts.on_exit(1, 1, nil)
end
return 1
end
local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_name(bufnr, "/tmp/output_fullname_all.test.ts")
vim.bo[bufnr].filetype = "typescript"
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {
'describe("outer", function() {',
' it("inner 1", function() {',
" -- inside 1",
" })",
"",
' it("inner 2", function() {',
" -- inside 2",
" })",
"})",
})
vim.api.nvim_set_current_buf(bufnr)
vim.api.nvim_win_set_cursor(0, { 7, 0 })
core.run_all()
local out_buf = vim.api.nvim_get_current_buf()
local lines = vim.api.nvim_buf_get_lines(out_buf, 0, -1, false)
vim.fn.jobstart = orig_jobstart
local has_pass = false
local has_skip = false
local has_fail = false
for _, line in ipairs(lines) do
if line == "[ PASS ] - outer inner 1" then
has_pass = true
elseif line == "[ SKIP ] - outer inner skip" then
has_skip = true
elseif line == "[ FAIL ] - outer inner 2" then
has_fail = true
end
end
assert.is_true(has_pass)
assert.is_true(has_skip)
assert.is_true(has_fail)
end)
it("formats jest verbose output for TSamAll as short names", function()
local check = string.char(0xE2, 0x9C, 0x93)
local cross = string.char(0xE2, 0x9C, 0x95)
local circle = string.char(0xE2, 0x97, 0x8B)
local orig_jobstart = vim.fn.jobstart
vim.fn.jobstart = function(_cmd, opts)
if opts and opts.on_stdout then
opts.on_stdout(1, {
" PASS /tmp/output_verbose_all.test.ts",
" " .. check .. " inner 1 (5 ms)",
" " .. circle .. " inner skip (skipped)",
" " .. cross .. " inner 2 (1 ms)",
}, nil)
end
if opts and opts.on_exit then
opts.on_exit(1, 1, nil)
end
return 1
end
local bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_name(bufnr, "/tmp/output_verbose_all.test.ts")
vim.bo[bufnr].filetype = "typescript"
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {
'describe("outer", function() {',
' it("inner 1", function() {',
" -- inside 1",
" })",
"",
' it("inner 2", function() {',
" -- inside 2",
" })",
"})",
})
vim.api.nvim_set_current_buf(bufnr)
vim.api.nvim_win_set_cursor(0, { 7, 0 })
core.run_all()
local out_buf = vim.api.nvim_get_current_buf()
@@ -338,6 +472,7 @@ describe("test-samurai output formatting", function()
has_raw_verbose = true
end
end
assert.is_true(has_pass)
assert.is_true(has_skip)
assert.is_true(has_fail)