Module:Hatnote/testcases
Appearance
![]() | This is the test cases page for the module Module:Hatnote. Results of the test cases. |
local mHatnote = require('Module:Hatnote') -- the module to be tested
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
function suite:assertError(func, ...)
local success, result = pcall(func, ...)
suite:assertFalse(success)
end
function suite:assertNotEquals(expected, actual)
suite:assertTrue(expected ~= actual)
end
-------------------------------------------------------------------------------
-- findNamespaceId tests
-------------------------------------------------------------------------------
function suite:testFindNamespaceIdInputErrors()
self:assertError(mHatnote.findNamespaceId, 9)
self:assertError(mHatnote.findNamespaceId)
self:assertError(mHatnote.findNamespaceId, 'A page', 9)
end
function suite:testFindNamespaceIdNamespaces()
self:assertEquals(0, mHatnote.findNamespaceId('Foo'))
self:assertEquals(2, mHatnote.findNamespaceId('User:Example'))
self:assertEquals(14, mHatnote.findNamespaceId('Category:Example'))
end
function suite:testFindNamespaceIdColonRemoval()
self:assertEquals(14, mHatnote.findNamespaceId(':Category:Example'))
end
function suite:testFindNamespaceIdSkipColonRemoval()
self:assertNotEquals(14, mHatnote.findNamespaceId(':Category:Example', false))
end
return suite