Module:Template link with magic/testcases: Difference between revisions
Appearance
create |
m Pppery moved page Module:Template link/testcases to Module:Tlm/testcases without leaving a redirect |
||
(No difference)
|
Revision as of 23:53, 22 April 2019
![]() | This is the test cases page for the module Module:Template link with magic. Results of the test cases. |
-- Test cases for [[Module:Template link]]. Click on the talk page to run the tests.
local tl = require('Module:Template link')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
local pipe = '|'
local equals = '='
local leftBrackets = '{{'
local rightBrackets = '}}'
function suite:testInvocationNoTemplate()
local success, message = pcall(tl.constructInvocation, {}, {})
self:assertFalse(success)
self:assertEquals('Template name not specified', message)
end
function suite:testInvocationNoParams()
self:assertEquals(leftBrackets .. 'Foo' .. rightBrackets, tl.constructInvocation({}, {template = 'Foo'}))
end
function suite:testInvocationLink()
self:assertEquals(leftBrackets .. '[[Template:Foo|Foo]]' .. rightBrackets, tl.constructInvocation({}, {template = 'Foo', link = true}))
end
function suite:testInvocationNowiki()
self:assertEquals(leftBrackets .. 'Foo' .. pipe .. mw.text.nowiki('[[Foo|Bar]]') .. rightBrackets, tl.constructInvocation({'[[Foo|Bar]]'}, {template = 'Foo', nowiki = true}))
end
function suite:testInvocationNotNowiki()
self:assertEquals(leftBrackets .. 'Foo' .. pipe .. '[[Foo|Bar]]' .. rightBrackets, tl.constructInvocation({'[[Foo|Bar]]'}, {template = 'Foo'}))
end
function suite:testInvocationNumberedParams()
self:assertEquals(leftBrackets .. 'Foo' .. pipe .. 'Bar' .. pipe .. 'Baz' .. rightBrackets, tl.constructInvocation({'Bar', 'Baz'}, {template = 'Foo'}))
end
function suite:testInvocationExplicitNumberedParams()
self:assertEquals(leftBrackets .. 'Foo' .. pipe .. '5' .. equals .. 'Bar' .. rightBrackets, tl.constructInvocation({[5] = 'Bar'}, {template = 'Foo'}))
end
function suite:testInvocationNamedParams()
self:assertEquals(leftBrackets .. 'Foo' .. pipe .. 'bar' .. equals .. 'Baz' .. rightBrackets, tl.constructInvocation({bar = 'Baz'}, {template = 'Foo'}))
end
return suite