Module:template parser/testcases

local tests = require "Module:UnitTests"

local parse_template = require "Module:template parser".parseTemplate local highlight = require "Module:debug".highlight { lang = "text" }

function tests:check_templates(examples) local options = { nowiki = true } tests:iterate(examples, function(self, wikitext, expected)		self:equals_deep(highlight(wikitext), {parse_template(wikitext)}, expected, options)	end) end

function tests:test_basic local examples = { {			"",			{ "link", { "en", "word" } }, },		{			"大老二", { "t", { "cmn", "大老二", tr = "" } }, },		{			"𒁀", { "t", { "akk", "𒁀", tr = " qiāšu, BA" } }, }	}	self:check_templates(examples) end

function tests:test_whitespace self:check_templates { { "", { "link", { " en ", " word\n" } } }, { "word\n", { "link", { " en ", "word" } } }, { "", { "link", { " word\n" } } }, } end

return tests