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:
parent
53ab4274c2
commit
e90f766ea3
8 changed files with 40 additions and 38 deletions
|
|
@ -1,14 +1,14 @@
|
|||
local t = require "spec.testutils"
|
||||
local _, T = t.setup "utils"
|
||||
local _, T, utils = t.setup "utils"
|
||||
|
||||
T["utils"]["should .remove_empty_lines()"] = function()
|
||||
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
|
||||
|
||||
T["utils"]["should .readfile_joined()"] = function()
|
||||
utils["should .readfile_joined()"] = function()
|
||||
local data = "line1\nline2\nline3"
|
||||
local tmp = t.tmpfile()
|
||||
local u = require "gopher._utils"
|
||||
|
|
@ -17,7 +17,7 @@ T["utils"]["should .readfile_joined()"] = function()
|
|||
t.eq(u.readfile_joined(tmp), data)
|
||||
end
|
||||
|
||||
T["utils"]["should .trimend()"] = function()
|
||||
utils["should .trimend()"] = function()
|
||||
local u = require "gopher._utils"
|
||||
t.eq(u.trimend " hi ", " hi")
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue