Skip to content

Commit

Permalink
notify suppression test
Browse files Browse the repository at this point in the history
  • Loading branch information
VorTechnix committed Oct 17, 2024
1 parent 0076010 commit 0915a83
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 2 additions & 3 deletions worldeditadditions_commands/commands/test/tests/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local test_id_paths = {
"credits.test.lua",
"notify.test.lua",
"notify_bad.test.lua",
-- "notify_suppress.test.lua",
-- "stacktrace.test.lua",
"notify_suppress.test.lua",
"stacktrace.test.lua",
}

-- Helper functions
Expand All @@ -13,7 +13,6 @@ local update = function(a,k,v) a[k] = v end
-- Test loader
local test_loader = function (path)
for _, v in ipairs(test_id_paths) do dofile(path .. v) end
return ret
end

return test_loader
Original file line number Diff line number Diff line change
@@ -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
})

0 comments on commit 0915a83

Please sign in to comment.