Module:TNT/testcases

-- Unit tests for Module:TNT. Click talk page to run tests. local p = require('Module:UnitTests') function p:test_msg -- dataset resolution self:preprocess_equals('', 'text message') self:preprocess_equals('', 'text message') self:preprocess_equals('', 'text message') self:preprocess_equals('', 'text message')

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

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

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

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

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

function p:test_doc local tnt = require('Module:TNT') self:equals_deep('templatedata 1',		tnt.getTemplateData('Module:TNT/testcases templatedata 1'),		'{"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"}}}',		{nowiki=1}) self:equals_deep('templatedata 2',		tnt.getTemplateData('Module:TNT/testcases templatedata 2'),		'{"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"}}}',		{nowiki=1}) end

return p