Module:Template link with magic/testcases: Difference between revisions
Appearance
Content deleted Content added
m Pppery moved page Module:Template link/testcases to Module:Tlm/testcases without leaving a redirect |
No edit summary |
||
Line 1: | Line 1: | ||
-- Test cases for [[Module:Template link]]. Click on the talk page to run the tests. |
-- Test cases for [[Module:Template link]]. Click on the talk page to run the tests. |
||
local tl = require('Module: |
local tl = require('Module:Tlm') |
||
local ScribuntoUnit = require('Module:ScribuntoUnit') |
local ScribuntoUnit = require('Module:ScribuntoUnit') |
||
local suite = ScribuntoUnit:new() |
local suite = ScribuntoUnit:new() |
Revision as of 02:22, 23 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: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