Jump to content

Module:Page assessment/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Evad37 (talk | contribs) at 03:49, 30 December 2020 (test getting wikitext of non-existent page). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- 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()

function suite:testGetWikitext(modToTest)
	-- From article
	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__sandbox()
	self:testGetWikitext(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