Module:Disambiguation/testcases explained

local mDab = require('Module:Disambiguation/sandbox')local ScribuntoUnit = require('Module:ScribuntoUnit')local mMockTitle = require('Module:Mock title')local suite = ScribuntoUnit:new

local dabPageTestData =

for _, data in ipairs(dabPageTestData) do mMockTitle.registerMockTitle

suite[string.format("test isDisambiguation: %s returns %s", data.description, tostring(data.expectedBool) )] = function (suite) suite:assertEquals(data.expectedBool, mDab.isDisambiguation(data.content)) end

suite[string.format("test _isDisambiguationPage: %s returns %s", data.description, tostring(data.expectedBool) )] = function (suite) local actual = mMockTitle.patchTitleConstructors(mDab._isDisambiguationPage, data.page ) suite:assertEquals(data.expectedBool, actual) end

suite[string.format('test isDisambiguationPage: %s returns "%s"', data.description, data.expectedText )] = function (suite) local frame = mw.getCurrentFrame:newChild local actual = mMockTitle.patchTitleConstructors(mDab.isDisambiguationPage, frame ) suite:assertEquals(data.expectedText, actual) endend

local dabContent =

for _, content in ipairs(dabContent) do suite[string.format('test isDisambiguation: content containing "%s" returns true', content )] = function (suite) suite:assertTrue(mDab.isDisambiguation(content)) endend

local nonDabContent =

for _, content in ipairs(nonDabContent) do suite[string.format('test isDisambiguation: content containing "%s" returns false', content )] = function (suite) suite:assertFalse(mDab.isDisambiguation(content)) endend

return suite