-- Unit tests for . Click on the talk page to-- run the tests.
local han = require('Module:Highest archive number/sandbox')local ScribuntoUnit = require('Module:ScribuntoUnit')local suite = ScribuntoUnit:new
-- Monkey patch mw.title.newlocal existingPages = local oldTitleNew = mw.title.newmw.title.new = function(page) local title = oldTitleNew(page) rawset(title, "exists", existingPages[page] ~= nil) return titleend
-- Test datalocal NO_ARCHIVES =
local ARCHIVES_1_TO_5 =
local ARCHIVES_3_TO_5 =
-- Testsfunction suite:testNoArchives existingPages = NO_ARCHIVES self:assertEquals(han._main("Talk:Foo/Archive "), nil)end
function suite:testArchivesStartingFromOne existingPages = ARCHIVES_1_TO_5 self:assertEquals(han._main("Talk:Foo/Archive "), 5)end
function suite:testArchivesStartingFromThreeWithCustomStart existingPages = ARCHIVES_3_TO_5 self:assertEquals(han._main("Talk:Foo/Archive ", 3), 5)end
function suite:testMain existingPages = ARCHIVES_3_TO_5 local frame = mw.getCurrentFrame local childFrame = frame:newChild self:assertEquals(han.main(childFrame), 5)end
function suite:testWrapperTemplate existingPages = ARCHIVES_1_TO_5 local frame = mw.getCurrentFrame local parentFrame = frame:newChild local childFrame = parentFrame:newChild self:assertEquals(han.main(childFrame), 5)end
return suite