Jump to content

Module:ApplyLinkAnnotations/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by N8wilson (talk | contribs) at 14:43, 12 June 2021 (raw). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Unit tests for [[Module:{{ROOTPAGENAME}}]]. Click talk page to run tests.
local p = require('Module:UnitTests')

-- Example unit test.
function p:test_hello()
	self:preprocess_equals('{{#invoke:Sandbox/N8wilson/ApplyLinkAnnotations|bySubstitutionInUnorderedList|hello}}', 'hello',{nowiki=1})
end

-- Test passing a link with no line breaks 
function p:test_same_line()
	self:equals('{{#invoke:Sandbox/N8wilson/ApplyLinkAnnotations|bySubstitutionInUnorderedList|*[[hello]]}}', '*[[hello]]')
end

-- Test updating a single un-piped link in a list
function p:test_one_item_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