Module:ApplyLinkAnnotations/testcases
Appearance
![]() | This is the test cases page for the module Module:ApplyLinkAnnotations. Results of the test cases. |
-- Unit tests for [[Module:{{ROOTPAGENAME}}]]. Click talk page to run tests.
local p = require('Module:UnitTests')
local m = require('Module:Sandbox/N8wilson/ApplyLinkAnnotations')
local t_match = {}
t_match["std list item"] = { "*[[hello]]", "* {{Annotated link |hello}}" }
t_match["pipe list item"] = { "*[[hello|hey]]", "* {{Annotated link |hello|hey}}" }
t_match["indented list item"] = { ":*[[related]]", ":* {{Annotated link |related}}" }
t_match["piped, indented item"] = { ":*[[related|renamed]]", ":* {{Annotated link |related|renamed}}" }
t_match["accented"] = { "*[[El Niño]]", "* {{Annotated link |El Niño}}" }
t_match["extra spaces"] = { "* [[Dark Matter]]", "* {{Annotated link |Dark Matter}}" }
function p:test_lines_to_match()
-- Various lines that should match
for name, case in pairs(t_match) do
self:equals(name,m._testline(case[1]),case[2],{nowiki=1})
end
end
function p:test_same_line()
-- Test passing a link with no line breaks
self:equals('same line',m.replaceLinksInUnorderedList('*[[hello]]'),'*[[hello]]',{nowiki=1})
end
function p:test_one_item_list()
-- Test updating a single un-piped link in a list
local supply = [==[List
*[[hello]]
]==]
local expect = [==[List
* {{Annotated link |hello}}
]==]
self:preprocess_equals('{{#invoke:Sandbox/N8wilson/ApplyLinkAnnotations|bySubstitutionInUnorderedList|'..supply..'}}', expect,{nowiki=1})
end
return p