Module:TNT/testcases

local TNT = require('Module:TNT') local ScribuntoUnit = require('Module:ScribuntoUnit') local p = ScribuntoUnit:new

function p:test_msg -- dataset resolution self:assertResultEquals('text message', '') self:assertResultEquals('text message', '') self:assertResultEquals('text message', '') self:assertResultEquals('text message', '')

-- spacing self:assertResultEquals('text message', '') self:assertResultEquals('text message', '') self:assertResultEquals('текст', '') self:assertResultEquals('text message', '')

-- 1 parameter self:assertResultEquals('text message a', '') self:assertResultEquals('text message a ', '') self:assertResultEquals('text message \na \n ', '') self:assertResultEquals('текст абв', '')

-- multiple parameters self:assertResultEquals('text message a and b', '') self:assertResultEquals('text message a  and  b ', '') self:assertResultEquals('text message \na \n  and  \nb \n ', '') self:assertResultEquals('текст абв и где', '')

-- parameters as part of wiki text self:assertResultEquals('text message a|b', '') self:assertResultEquals('text message b ', '') self:assertResultEquals('текст где', '')

-- fallbacks self:assertResultEquals('текст', '') self:assertResultEquals('текст', '') self:assertResultEquals('текст', '') end

function p:test_msg_errors self:assertResultEquals(' Lua error: bad argument #1 to &quot;get&quot; (not a valid title). ', '') end

function p:test_link self:assertResultEquals('commons:Data:abc.tab', '') self:assertResultEquals('commons:Data:abc.tab', '') self:assertResultEquals('commons:Data:abc.tab', '') end

function p:test_doc local tnt = require('Module:TNT') self:assertEquals(	   '{"paramOrder":["1","2"],"description":"DO NOT EDIT OR TRANSLATE unless you are changing unit tests","params":{"1":{"suggested":false,"type":"string","required":true,"label":"en_label_1","example":"en_example_1","description":"en_desc_1"},"2":{"suggested":true,"type":"string","required":false,"label":"fr_label_2","example":"pl_example_2","description":"en_desc_2"}}}',	    tnt.getTemplateData('Module:TNT/testcases templatedata 1'),	    'templatedata 1') self:assertEquals(       '{"paramOrder":["param1","param2"],"description":"DO NOT EDIT OR TRANSLATE unless you are changing unit tests","params":{"param2":{"suggested":true,"type":"string","required":false,"label":"fr_label_2","example":"pl_example_2","description":"en_desc_2"},"param1":{"suggested":false,"type":"string","required":true,"label":"en_label_1","example":"en_example_1","description":"en_desc_1"}}}',        tnt.getTemplateData('Module:TNT/testcases templatedata 2'),        'templatedata 2') end

return p