<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AFormat_link%2Ftestcases</id>
	<title>Module:Format link/testcases - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AFormat_link%2Ftestcases"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Format_link/testcases&amp;action=history"/>
	<updated>2026-04-04T02:16:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Format_link/testcases&amp;diff=136313&amp;oldid=prev</id>
		<title>imported&gt;Psiĥedelisto: add tests</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Format_link/testcases&amp;diff=136313&amp;oldid=prev"/>
		<updated>2021-12-29T15:52:37Z</updated>

		<summary type="html">&lt;p&gt;add tests&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Unit tests for [[Module:Format link]]&lt;br /&gt;
local mFormatLink = require(&amp;#039;Module:Format link/sandbox&amp;#039;)&lt;br /&gt;
local scribuntoUnit = require(&amp;#039;Module:ScribuntoUnit&amp;#039;)&lt;br /&gt;
local suite = scribuntoUnit:new()&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
-- Testing helper functions&lt;br /&gt;
--------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function suite:assertParentFrameCallEquals(expected, func, args)&lt;br /&gt;
	args = args or {}&lt;br /&gt;
	local current = mw.getCurrentFrame()&lt;br /&gt;
	local parent = current:newChild{title = &amp;#039;Parent&amp;#039;, args = args}&lt;br /&gt;
	local child = parent:newChild{title = &amp;#039;Child&amp;#039;}&lt;br /&gt;
	self:assertEquals(expected, func(child))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- formatLink tests&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLink()&lt;br /&gt;
	self:assertEquals(&amp;#039;[[:Foo]]&amp;#039;, mFormatLink._formatLink{link = &amp;#039;Foo&amp;#039;})&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkColonHandling()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;#039;[[:Category:Foo]]&amp;#039;,&lt;br /&gt;
		mFormatLink._formatLink{link = &amp;#039;:Category:Foo&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkSectionLinking()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;#039;[[:Foo#Bar|Foo §&amp;amp;nbsp;Bar]]&amp;#039;,&lt;br /&gt;
		mFormatLink._formatLink{link = &amp;#039;Foo#Bar&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkPipeHandling()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;#039;[[:Foo|Bar]]&amp;#039;,&lt;br /&gt;
		mFormatLink._formatLink{link = &amp;#039;Foo|Bar&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkDisplay()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;#039;[[:Foo|Bar]]&amp;#039;,&lt;br /&gt;
		mFormatLink._formatLink{link = &amp;#039;Foo&amp;#039;, display = &amp;#039;Bar&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkDisplayOverwritesManualPiping()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;#039;[[:Foo|Baz]]&amp;#039;,&lt;br /&gt;
		mFormatLink._formatLink{link = &amp;#039;Foo|Bar&amp;#039;, display = &amp;#039;Baz&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkPageItalicization()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;quot;[[:Foo|&amp;lt;i&amp;gt;Foo&amp;lt;/i&amp;gt;]]&amp;quot;,&lt;br /&gt;
		mFormatLink._formatLink{link = &amp;#039;Foo&amp;#039;, italicizePage = true}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkPageItalicizationWithSection()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;quot;[[:Foo#Bar|&amp;lt;i&amp;gt;Foo&amp;lt;/i&amp;gt; §&amp;amp;nbsp;Bar]]&amp;quot;,&lt;br /&gt;
		mFormatLink._formatLink{link = &amp;#039;Foo#Bar&amp;#039;, italicizePage = true}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkSectionItalicization()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;quot;[[:Foo#Bar|Foo §&amp;amp;nbsp;&amp;lt;i&amp;gt;Bar&amp;lt;/i&amp;gt;]]&amp;quot;,&lt;br /&gt;
		mFormatLink._formatLink{link = &amp;#039;Foo#Bar&amp;#039;, italicizeSection = true}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkPageItalicizationIsOverwrittenByDisplay()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;quot;[[:Foo#Bar|Baz]]&amp;quot;,&lt;br /&gt;
		mFormatLink._formatLink{&lt;br /&gt;
			link = &amp;#039;Foo#Bar&amp;#039;,&lt;br /&gt;
			display = &amp;#039;Baz&amp;#039;,&lt;br /&gt;
			italicizePage = true,&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkSectionItalicizationIsOverwrittenByDisplay()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;quot;[[:Foo#Bar|Baz]]&amp;quot;,&lt;br /&gt;
		mFormatLink._formatLink{&lt;br /&gt;
			link = &amp;#039;Foo#Bar&amp;#039;,&lt;br /&gt;
			display = &amp;#039;Baz&amp;#039;,&lt;br /&gt;
			italicizeSection = true,&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkItalicizationIsOverwrittenByManualPiping()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;quot;[[:Foo#Bar|Baz]]&amp;quot;,&lt;br /&gt;
		mFormatLink._formatLink{&lt;br /&gt;
			link = &amp;#039;Foo#Bar|Baz&amp;#039;,&lt;br /&gt;
			italicizePage = true,&lt;br /&gt;
			italicizeSection = true,&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkWithSectionOnlyLink()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;quot;[[:#Section|§&amp;amp;nbsp;Section]]&amp;quot;,&lt;br /&gt;
		mFormatLink._formatLink{&lt;br /&gt;
			link = &amp;#039;#Section&amp;#039;,&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkWithSectionOnlyLinkAndItalicizedSection()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;quot;[[:#Section|§&amp;amp;nbsp;&amp;lt;i&amp;gt;Section&amp;lt;/i&amp;gt;]]&amp;quot;,&lt;br /&gt;
		mFormatLink._formatLink{&lt;br /&gt;
			link = &amp;#039;#Section&amp;#039;,&lt;br /&gt;
			italicizeSection = true,&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkWithSectionOnlyLinkAndItalicizedPage()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;quot;[[:#Section|§&amp;amp;nbsp;Section]]&amp;quot;,&lt;br /&gt;
		mFormatLink._formatLink{&lt;br /&gt;
			link = &amp;#039;#Section&amp;#039;,&lt;br /&gt;
			italicizePage=true,&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkEntryPoint()&lt;br /&gt;
	self:assertParentFrameCallEquals(&amp;#039;[[:Foo]]&amp;#039;, mFormatLink.formatLink, {&amp;#039;Foo&amp;#039;})&lt;br /&gt;
	self:assertParentFrameCallEquals(&lt;br /&gt;
		&amp;#039;[[:Foo|Bar]]&amp;#039;,&lt;br /&gt;
		mFormatLink.formatLink, {&amp;#039;Foo&amp;#039;, &amp;#039;Bar&amp;#039;}&lt;br /&gt;
	)&lt;br /&gt;
	self:assertParentFrameCallEquals(&lt;br /&gt;
		&amp;quot;[[:Foo#Bar|&amp;lt;i&amp;gt;Foo&amp;lt;/i&amp;gt; §&amp;amp;nbsp;&amp;lt;i&amp;gt;Bar&amp;lt;/i&amp;gt;]]&amp;quot;,&lt;br /&gt;
		mFormatLink.formatLink,&lt;br /&gt;
		{&amp;#039;Foo#Bar&amp;#039;, italicizepage=&amp;quot;yes&amp;quot;, italicizesection=&amp;quot;yes&amp;quot;}&lt;br /&gt;
	)&lt;br /&gt;
	self:assertParentFrameCallEquals(&lt;br /&gt;
		&amp;quot;[[:Foo#Bar|Foo §&amp;amp;nbsp;Bar]]&amp;quot;,&lt;br /&gt;
		mFormatLink.formatLink,&lt;br /&gt;
		{&amp;#039;Foo#Bar&amp;#039;, italicizepage=&amp;quot;no&amp;quot;, italicizesection=&amp;quot;no&amp;quot;}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkNonexistentPageCategorization()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;#039;[[:Nonexistent page]][[Category:Test]]&amp;#039;,&lt;br /&gt;
		mFormatLink._formatLink{&lt;br /&gt;
			link = &amp;#039;Nonexistent page&amp;#039;, --*should* be nonexistent; is salted&lt;br /&gt;
			categorizeMissing = &amp;#039;Test&amp;#039;&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkTarget()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;#039;[[:Baz|Foo §&amp;amp;nbsp;Bar]]&amp;#039;,&lt;br /&gt;
		mFormatLink._formatLink{&lt;br /&gt;
			link = &amp;quot;Foo#Bar&amp;quot;,&lt;br /&gt;
			target = &amp;#039;Baz&amp;#039;&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatLinkTargetPiping()&lt;br /&gt;
	self:assertEquals(&lt;br /&gt;
		&amp;#039;[[:Baz|Boop]]&amp;#039;,&lt;br /&gt;
		mFormatLink._formatLink{&lt;br /&gt;
			link = &amp;quot;Foo#Bar|Boop&amp;quot;,&lt;br /&gt;
			target = &amp;#039;Baz&amp;#039;&lt;br /&gt;
		}&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
-- formatPages tests&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
function suite:testFormatPages()&lt;br /&gt;
	self:assertDeepEquals(&lt;br /&gt;
		{&amp;#039;[[:Foo]]&amp;#039;, &amp;#039;[[:Bar]]&amp;#039;},&lt;br /&gt;
		mFormatLink.formatPages({}, {&amp;#039;Foo&amp;#039;, &amp;#039;Bar&amp;#039;})&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return suite&lt;/div&gt;</summary>
		<author><name>imported&gt;Psiĥedelisto</name></author>
	</entry>
</feed>