gopher.nvim/spec/unit/utils_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

25 lines
611 B
Lua

local t = require "spec.testutils"
local _, T, utils = t.setup "utils"
utils["should .remove_empty_lines()"] = function()
local u = require "gopher._utils"
local inp = { "hi", "", "a", "", "", "asdf" }
t.eq(u.remove_empty_lines(inp), { "hi", "a", "asdf" })
end
utils["should .readfile_joined()"] = function()
local data = "line1\nline2\nline3"
local tmp = t.tmpfile()
local u = require "gopher._utils"
t.writefile(tmp, data)
t.eq(u.readfile_joined(tmp), data)
end
utils["should .trimend()"] = function()
local u = require "gopher._utils"
t.eq(u.trimend " hi ", " hi")
end
return T