-- Unit tests for local mFormatLink = require('Module:Format link/sandbox')local scribuntoUnit = require('Module:ScribuntoUnit')local suite = scribuntoUnit:new
---------------------------------------------------------------------------------- Testing helper functions--------------------------------------------------------------------------------
function suite:assertParentFrameCallEquals(expected, func, args) args = args or local current = mw.getCurrentFrame local parent = current:newChild local child = parent:newChild self:assertEquals(expected, func(child))end
--------------------------------------------------------------------------------- formatLink tests-------------------------------------------------------------------------------
function suite:testFormatLink self:assertEquals('', mFormatLink._formatLink)end
function suite:testFormatLinkColonHandling self:assertEquals('', mFormatLink._formatLink )end
function suite:testFormatLinkSectionLinking self:assertEquals('Foo § Bar', mFormatLink._formatLink )end
function suite:testFormatLinkPipeHandling self:assertEquals('Bar', mFormatLink._formatLink )end
function suite:testFormatLinkDisplay self:assertEquals('Bar', mFormatLink._formatLink )end
function suite:testFormatLinkDisplayOverwritesManualPiping self:assertEquals('Baz', mFormatLink._formatLink )end
function suite:testFormatLinkPageItalicization self:assertEquals("Foo", mFormatLink._formatLink )end
function suite:testFormatLinkPageItalicizationWithSection self:assertEquals("Foo § Bar", mFormatLink._formatLink )end
function suite:testFormatLinkSectionItalicization self:assertEquals("Foo § Bar", mFormatLink._formatLink )end
function suite:testFormatLinkPageItalicizationIsOverwrittenByDisplay self:assertEquals("Baz", mFormatLink._formatLink )end
function suite:testFormatLinkSectionItalicizationIsOverwrittenByDisplay self:assertEquals("Baz", mFormatLink._formatLink )end
function suite:testFormatLinkItalicizationIsOverwrittenByManualPiping self:assertEquals("Baz", mFormatLink._formatLink )end
function suite:testFormatLinkWithSectionOnlyLink self:assertEquals("§ Section", mFormatLink._formatLink )end
function suite:testFormatLinkWithSectionOnlyLinkAndItalicizedSection self:assertEquals("§ Section", mFormatLink._formatLink )end
function suite:testFormatLinkWithSectionOnlyLinkAndItalicizedPage self:assertEquals("§ Section", mFormatLink._formatLink )end
function suite:testFormatLinkEntryPoint self:assertParentFrameCallEquals('', mFormatLink.formatLink,) self:assertParentFrameCallEquals('Bar', mFormatLink.formatLink, ) self:assertParentFrameCallEquals("Foo § Bar", mFormatLink.formatLink, ) self:assertParentFrameCallEquals("Foo § Bar", mFormatLink.formatLink, )end
function suite:testFormatLinkNonexistentPageCategorization self:assertEquals('', mFormatLink._formatLink )end
function suite:testFormatLinkTarget self:assertEquals('Foo § Bar', mFormatLink._formatLink )end
function suite:testFormatLinkTargetPiping self:assertEquals('Boop', mFormatLink._formatLink )end
--------------------------------------------------------------------------------- formatPages tests-------------------------------------------------------------------------------
function suite:testFormatPages self:assertDeepEquals(mFormatLink.formatPages )end
return suite