Module:Link if exists/testcases
Appearance
| This is the test cases page for the module Module:Link if exists. Results of the test cases. |
-- Unit tests for [[Module:{{subst:ROOTPAGENAME}}]]. Click talk page to run tests.
local p = require('Module:UnitTests')
local testPairs = {
{'a','[[A|a]]'},
{'Sierra Nevada','[[Sierra Nevada]]'},
{' ',' '},
{'aqrp','aqrp'},
{'A|letter a','[[A|letter a]]'},
{'aqrp|,asmd',',asmd'},
{'Cite USGov|prefix=Template','[[:Template:Cite USGov]]'},
{'Flying monkeys|prefix=Template','Flying monkeys'},
{'Notability|nsp=Wikipedia','[[:Wikipedia:Notability|Notability]]'},
{'Deliciousness|nsp=Wikipedia','Deliciousness'},
{'Aalborg|prefix=Template|Ålborg','[[:Template:Aalborg|Ålborg]]'},
{'United States|nsp=Category|color=#888','[[:Category:United States|United States]]'},
{'A non-existent category|nsp=Category|color=#888','<span style="color:#888">A non-existent category</span>'},
{'United States|USA|nsp=Category|color=#888','[[:Category:United States|USA]]'},
{'A non-existent category|Foo|nsp=Category|color=#888','<span style="color:#888">Foo</span>'},
{'United States|USA|nsp=Category|color=#888|hide_display=1','[[:Category:United States|USA]]'},
{'A non-existent category|Foo|nsp=Category|color=#888|hide_display=1',''},
}
function p:test_main()
self:preprocess_equals_many('{{#invoke:Link if exists|main|','}}', testPairs)
end
function p:test_sandbox()
self:preprocess_equals_many('{{#invoke:Link if exists/sandbox|main|','}}',testPairs)
end
return p