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', '', 'msg00') self:assertResultEquals('text message', '', 'msg01') self:assertResultEquals('text message', '', 'msg02') self:assertResultEquals('text message', '', 'msg03')

-- spacing self:assertResultEquals('text message', '', 'msg10') self:assertResultEquals('text message', '', 'msg11') self:assertResultEquals('текст', '', 'msg12') self:assertResultEquals('text message', '', 'msg13')

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

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

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

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

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

function p:test_link self:assertResultEquals('commons:Data:abc.tab', '', 'link00') self:assertResultEquals('commons:Data:abc.tab', '', 'link01') self:assertResultEquals('commons:Data:abc.tab', '', 'link02') 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'),            'doc00') 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'),            'doc01') end

return p