Jump to content

Module:Template invocation/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Andrybak (talk | contribs) at 09:30, 23 May 2020 (try using Module:ScribuntoUnit). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Unit tests for [[Module:Template invocation]]. Click talk page to run tests.
local ScribuntoUnit = require('Module:ScribuntoUnit')
local p = ScribuntoUnit:new()
local protect = require('Module:Protect')

local function test(a)
	local mTemplateInvocation = require('Module:Template invocation')
	local mTemplateInvocation2 = require('Module:Template invocation/sandbox')
	local liveRes = protect(mTemplateInvocation.invocation)('foo', a)
	local sandboxRes = protect(mTemplateInvocation2.invocation)('foo', a)
	p:assertEquals(liveRes, sandboxRes)
end

function p:test_hello()
	local a = {'bar', 'baz', abc = 'def'}; a[6]=666; a[7]=777; a['7']='777s'; a[3]=333; a['4']='444s'
	return test(a)
end

function p:test_equals_sign()
	local a = {'bar', 'baz', '{{=}}'}
	return test(a)
end

function p:test_numbered()
	local a = {}
	a[1] = 'aaa'
	a[2] = 'bbb'
	a[5] = 'eee'
	return test(a)
end

return p