Module:Highest archive number/testcases
Appearance
![]() | This is the test cases page for the module Module:Highest archive number. Results of the test cases. |
-- Unit tests for [[Module:Highest archive number]]. 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.new
local existingPages = {}
mw.title.new = function(page)
return {exists = existingPages[page] ~= nil}
end
function suite:testNoArchives()
existingPages = {}
self:assertEquals(han._main("Talk:Foo/Archive "), nil)
end
function suite:testArchivesStartingFromOne()
existingPages = {
["Talk:Foo/Archive 1"] = true,
["Talk:Foo/Archive 2"] = true,
["Talk:Foo/Archive 3"] = true,
["Talk:Foo/Archive 4"] = true,
["Talk:Foo/Archive 5"] = true,
}
self:assertEquals(han._main("Talk:Foo/Archive "), 5)
end
function suite:testArchivesStartingFromThreeWithCustomStart()
existingPages = {
["Talk:Foo/Archive 3"] = true,
["Talk:Foo/Archive 4"] = true,
["Talk:Foo/Archive 5"] = true,
}
self:assertEquals(han._main("Talk:Foo/Archive ", 3), 5)
end
function suite:testMain()
existingPages = {
["Talk:Foo/Archive 3"] = true,
["Talk:Foo/Archive 4"] = true,
["Talk:Foo/Archive 5"] = true,
}
self:assertEquals(han.main{"Talk:Foo/Archive ", start="3"}, 5)
end
return suite