Module:Page assessment/testcases
Appearance
![]() | This is the test cases page for the module Module:Page assessment. Results of the test cases. |
-- Unit tests for [[Module:Page assessment}}]]. Click talk page to run tests.
local ScribuntoUnit = require('Module:ScribuntoUnit')
local liveMod = require('Module:Page assessment').util -- the module to be tested
local sandbox = require('Module:Page assessment/sandbox').test -- the module to be tested
local suite = ScribuntoUnit:new()
--[[
Tescase naming convention:
- Live module tests: "test" + MethodName + "_" + description
(use camel case either side of the underscore, e.g. testFoo_barBaz,
not testfoo_barBaz, nor testFoo_BarBaz, nor testfoo_barbaz, etc.)
- Sandbox module tests: As above, suffixed with "__sandbox"
(note the *double* undersecore)
This ensures the results page has descriptive names for all tests, and that
sandbox tests appear directly after live module tests.
]]--
function suite:testGetWikitext_fromArticle(modToTest)
modToTest = modToTest or liveMod
local subjectWikitext, talkWikitext = modToTest.getWikitext("Wikipedia")
self:assertTrue(mw.ustring.len(subjectWikitext) > 100, "Wikitext of page 'Wikipedia' more than 100 chars")
self:assertTrue(mw.ustring.len(subjectWikitext) > 100, "Wikitext of page 'Talk:Wikipedia' more than 100 chars")
self:assertFalse(subjectWikitext == talkWikitext, "Subject page is different to talk page")
end
function suite:testGetWikitext_fromArticle__sandbox() return self:testGetWikitext_fromArticle(sandbox) end
function suite:testGetWikitext_fromTalk(modToTest)
modToTest = modToTest or liveMod
local subjectWikitext1, talkWikitext1 = modToTest.getWikitext("Wikipedia")
local subjectWikitext2, talkWikitext2 = modToTest.getWikitext("Talk:Wikipedia")
self:assertEquals(subjectWikitext1, subjectWikitext2, "Subject page of 'Wikipedia' is same as subject page of 'Talk:Wikipedia'")
self:assertEquals(talkWikitext1, talkWikitext2, "Talk page of 'Wikipedia' is same as talk page of 'Talk:Wikipedia'")
end
function suite:testGetWikitext_fromTalk__sandbox() return self:testGetWikitext_fromTalk(sandbox) end
function suite:testGetWikitext_nonExisting(modToTest)
modToTest = modToTest or liveMod
local subjectWikitext, talkWikitext = modToTest.getWikitext("Wikipediadsgvbjfdoibtdhbntrsnsr")
self:assertEquals(subjectWikitext, nil, "Nil result for subject page wikitext")
self:assertEquals(talkWikitext, nil, "Nil result for talk page wikitext")
end
function suite:testGetWikitext_nonExisting__sandbox() return self:testGetWikitext_nonExisting(sandbox) end
--[[
function suite:testSomeOtherCall()
self:assertEquals('expected value', myModule.someOtherCall(123))
self:assertEquals('other expected value', myModule.someOtherCall(456))
end
]]--
return suite