请输入您要查询的百科知识:

 

词条 Module:Template link/testcases
释义 -- Test cases for 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 .. 'Foo' .. rightBrackets, tl.constructInvocation({}, {template = 'Foo', link = true}))

end

function suite:testInvocationNowiki()

self:assertEquals(leftBrackets .. 'Foo' .. pipe .. mw.text.nowiki('Bar') .. rightBrackets, tl.constructInvocation({'Bar'}, {template = 'Foo', nowiki = true}))

end

function suite:testInvocationNotNowiki()

self:assertEquals(leftBrackets .. 'Foo' .. pipe .. 'Bar' .. rightBrackets, tl.constructInvocation({'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

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 21:54:43