From 86069f37686e5709411f1b9e97c0f664dc8a833e Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 16 Jul 2015 13:00:51 +0100 Subject: Add html extraction unit test. --- test/lua/unit/html.lua | 31 +++++++++++++++++++++++++++++++ test/lua/unit/task.lua | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 test/lua/unit/html.lua (limited to 'test') diff --git a/test/lua/unit/html.lua b/test/lua/unit/html.lua new file mode 100644 index 000000000..5c58e209a --- /dev/null +++ b/test/lua/unit/html.lua @@ -0,0 +1,31 @@ +context("HTML processing", function() + local rspamd_util = require("rspamd_util") + local logger = require("rspamd_logger") + + test("Extract text from HTML", function() + local cases = { + {[[ + + + + + title + + + + + + Hello, world! + + + ]], 'Hello, world!'}, + } + + for _,c in ipairs(cases) do + local t = rspamd_util.parse_html(c[1]) + + assert_not_nil(t) + assert_equal(c[2], tostring(t)) + end + end) +end) \ No newline at end of file diff --git a/test/lua/unit/task.lua b/test/lua/unit/task.lua index ef38c02a3..ed61fb3c5 100644 --- a/test/lua/unit/task.lua +++ b/test/lua/unit/task.lua @@ -38,7 +38,7 @@ Content-Type: text/plain Test. ]] - local obj = rspamd_util.process_message(cfg, msg) - print(logger.slog("result: %1", obj)) + --local obj = rspamd_util.process_message(cfg, msg) + --print(logger.slog("result: %1", obj)) end) end) \ No newline at end of file -- cgit v1.2.3