From 0915a83151c9855bcc485e5ca2ad9b4bff54a8d1 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Thu, 17 Oct 2024 08:51:18 -0700 Subject: [PATCH] notify suppression test --- .../commands/test/tests/init.lua | 5 ++--- .../test/tests/notify_suppress.test.lua | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/worldeditadditions_commands/commands/test/tests/init.lua b/worldeditadditions_commands/commands/test/tests/init.lua index d2efccc..2461f73 100644 --- a/worldeditadditions_commands/commands/test/tests/init.lua +++ b/worldeditadditions_commands/commands/test/tests/init.lua @@ -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 @@ -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 \ No newline at end of file diff --git a/worldeditadditions_commands/commands/test/tests/notify_suppress.test.lua b/worldeditadditions_commands/commands/test/tests/notify_suppress.test.lua index e69de29..f1da0e3 100644 --- a/worldeditadditions_commands/commands/test/tests/notify_suppress.test.lua +++ b/worldeditadditions_commands/commands/test/tests/notify_suppress.test.lua @@ -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 +}) \ No newline at end of file