mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 23:42:59 +00:00
notify suppression test
This commit is contained in:
parent
0076010f35
commit
0915a83151
2 changed files with 22 additions and 3 deletions
|
@ -3,8 +3,8 @@ local test_id_paths = {
|
||||||
"credits.test.lua",
|
"credits.test.lua",
|
||||||
"notify.test.lua",
|
"notify.test.lua",
|
||||||
"notify_bad.test.lua",
|
"notify_bad.test.lua",
|
||||||
-- "notify_suppress.test.lua",
|
"notify_suppress.test.lua",
|
||||||
-- "stacktrace.test.lua",
|
"stacktrace.test.lua",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Helper functions
|
-- Helper functions
|
||||||
|
@ -13,7 +13,6 @@ local update = function(a,k,v) a[k] = v end
|
||||||
-- Test loader
|
-- Test loader
|
||||||
local test_loader = function (path)
|
local test_loader = function (path)
|
||||||
for _, v in ipairs(test_id_paths) do dofile(path .. v) end
|
for _, v in ipairs(test_id_paths) do dofile(path .. v) end
|
||||||
return ret
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return test_loader
|
return test_loader
|
|
@ -0,0 +1,20 @@
|
||||||
|
local Notify = worldeditadditions_core.notify
|
||||||
|
worldeditadditions.normalize_test("suppress", {
|
||||||
|
params = "N/A",
|
||||||
|
description = "Tests notification suppression system.",
|
||||||
|
func = function(name, params_table)
|
||||||
|
Notify.suppress_for_player(name, 5)
|
||||||
|
Notify.warn(name, "This message should not be shown.")
|
||||||
|
Notify.suppress_for_player(name, -1)
|
||||||
|
Notify.ok(name, "This message should be shown.")
|
||||||
|
local result = Notify.suppress_for_function(name, function()
|
||||||
|
Notify.error(name, "This message should not be shown.")
|
||||||
|
return true
|
||||||
|
end)
|
||||||
|
if not result then
|
||||||
|
Notify.error(name, "Error: suppress_for_function did not call function.")
|
||||||
|
else
|
||||||
|
Notify.ok(name, "suppress_for_function called function.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
Loading…
Reference in a new issue