Module:Template link with magic/testcases: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
Current testcases are testing a version of the module that was overwritten in 2014, convert to redirect to template testcases Tag: New redirect |
||
Line 1: | Line 1: | ||
#REDIRECT [[Template:Tlm/testcases]] |
|||
-- Test cases for [[Module:Tlm]]. Click on the talk page to run the tests. |
|||
local tl = require('Module:Tlm') |
|||
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 |
Revision as of 19:01, 5 October 2021
Redirect to: