local mClassMask = require('Module:Class mask/sandbox')local ScribuntoUnit = require('Module:ScribuntoUnit')local suite = ScribuntoUnit:newlocal frame = mw.getCurrentFramelocal lang = mw.language.getContentLanguage
--------------------------------------------------------------------------------- Helper functions-------------------------------------------------------------------------------local function classMask(args, page) local title = page and mw.title.new(page).talkPageTitle return mClassMask._main(args, title)end
local function copyTable(t1, t2) for k, v in pairs(t2) do t1[k] = v endend
local function unity(t1, t2) local ret = copyTable(ret, t1) copyTable(ret, t2) return retend
--------------------------------------------------------------------------------- Custom assert methods-------------------------------------------------------------------------------function suite:assertGradeEquals(expected, grade, args, page) self:assertEquals(expected, classMask(unity(args,), page)) self:assertEquals(expected, classMask(unity(args,), page)) self:assertEquals(expected, classMask(unity(args,), page))end
--------------------------------------------------------------------------------- Default scale tests-------------------------------------------------------------------------------local function makeDefaultScaleTests(t) suite['test_' .. t.name] = function (self) self:assertGradeEquals(t.expected, t.trigger,, t.page) end suite['test_' .. t.name .. '_no'] = function (self) self:assertGradeEquals(, t.trigger,, t.page) end suite['test_' .. t.name .. '_on_redirect'] = function (self) self:assertGradeEquals('Redirect', t.trigger,, 'Abdul, Paula') end
endmakeDefaultScaleTestsmakeDefaultScaleTestsmakeDefaultScaleTestsmakeDefaultScaleTestsmakeDefaultScaleTestsmakeDefaultScaleTestsmakeDefaultScaleTestsmakeDefaultScaleTestsmakeDefaultScaleTests
--------------------------------------------------------------------------------- Full quality scale grade tests-------------------------------------------------------------------------------local function makeFQSTests(t) suite['test_' .. t.name .. '_default'] = function (self) self:assertGradeEquals('NA', t.trigger,, t.page) end suite['test_' .. t.name .. '_activated'] = function (self) self:assertGradeEquals(t.expected, t.trigger,, t.page) end if t.aliases then suite['test_' .. t.name .. '_aliases'] = function (self) for _, alias in ipairs(t.aliases) do self:assertGradeEquals(t.expected, alias,, t.page) end end end suite['test_' .. t.name .. '_FQS'] = function (self) self:assertGradeEquals(t.expected, t.trigger,, t.page) endend
makeFQSTestsmakeFQSTestsmakeFQSTestsmakeFQSTestsmakeFQSTestsmakeFQSTestsmakeFQSTestsmakeFQSTests
--------------------------------------------------------------------------------- Help tests-------------------------------------------------------------------------------function suite:test_help_default self:assertGradeEquals('NA', 'Help',, 'Help:Footnotes')end
function suite:test_help_activated self:assertGradeEquals('Help', 'Help',, 'Help:Footnotes')end
function suite:test_help_FQS self:assertGradeEquals('NA', 'Help',, 'Help:Footnotes')end
--------------------------------------------------------------------------------- FM tests-------------------------------------------------------------------------------function suite:test_FM_default self:assertGradeEquals('NA', 'FM',, 'File:Alamo pano.jpg')endfunction suite:test_FM_activated self:assertGradeEquals('FM', 'FM',, 'File:Alamo pano.jpg')endfunction suite:test_FM_file_activated self:assertGradeEquals('File', 'FM',, 'File:Alamo pano.jpg')endfunction suite:test_FM_file_FQS self:assertGradeEquals('FM', 'FM',, 'File:Alamo pano.jpg')endfunction suite:test_FM_file_overridden self:assertGradeEquals('FM', 'FM',, 'File:Alamo pano.jpg')end
--------------------------------------------------------------------------------- Module tests-------------------------------------------------------------------------------function suite:test_module_default self:assertGradeEquals('NA', 'module',)endfunction suite:test_module_activated self:assertGradeEquals('NA', 'module',)endfunction suite:test_module_template_activated self:assertGradeEquals('Template', 'Module',)endfunction suite:test_module_template_FQS self:assertGradeEquals('Template', 'Module',)endfunction suite:test_module_template_overridden self:assertGradeEquals('NA', 'module',)end
--------------------------------------------------------------------------------- Undefined tests-------------------------------------------------------------------------------function suite:test_undefined self:assertEquals('¬', classMask)endfunction suite:test_undefined_explicit self:assertEquals('¬', classMask)end
--------------------------------------------------------------------------------- Default grade tests-------------------------------------------------------------------------------local function makeDefaultTests(t) suite['test_default_' .. t.name .. '_inactive'] = function (self) self:assertGradeEquals('NA', 'Foo',, t.page) end suite['test_default_' .. t.name .. '_active'] = function (self) self:assertGradeEquals(t.expected, 'Foo',, t.page) end suite['test_default_' .. t.name .. '_FQS'] = function (self) self:assertGradeEquals(t.FQSexpected or t.expected, 'Foo',, t.page) end suite['test_default_' .. t.name .. '_FQS_overridden'] = function (self) self:assertGradeEquals(t.FQSexpected or 'NA', 'Foo',, t.page) endend
makeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTestsmakeDefaultTests
function suite:test_default_other_namespace self:assertGradeEquals(, 'Foo',, 'Talk:Foo2')endfunction suite:test_default_upper_exists self:assertGradeEquals('Some grade', 'Foo',, 'Phil Ouellette')endfunction suite:test_default_lower_exists self:assertGradeEquals('Foo', 'foO',, 'Phil Ouellette')endfunction suite:test_default_lower_overridden self:assertGradeEquals('Some grade', 'Foo',, 'Phil Ouellette')endfunction suite:test_default_empty_exists self:assertGradeEquals('Some grade', ,, 'Phil Ouellette')endfunction suite:test_default_blank_exists self:assertGradeEquals('Some grade', ' ',, 'Phil Ouellette')endfunction suite:test_auto_disambig self:assertGradeEquals('Disambig', ,, 'Talk:Resilience')endfunction suite:test_auto_disambig2 self:assertGradeEquals('Disambig', ,, 'Talk:0K')endfunction suite:test_auto_disambig3 self:assertGradeEquals('NA', ,, "Talk:St. Paul's Cathedral (disambiguation)")endfunction suite:test_soft_redirect self:assertGradeEquals('NA', ,, "'Murica")end
--------------------------------------------------------------------------------- Other tests-------------------------------------------------------------------------------function suite:test_whitespace self:assertEquals('FA', classMask('Phil Ouellette'))end
return suite