------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Unit tests for . Click talk page to run tests.local ubx = require('Module:Userbox')local ScribuntoUnit = require('Module:ScribuntoUnit')local suite = ScribuntoUnit:new
local userbox = ubx['_userbox']local userbox2 = ubx['_userbox-2']local userboxr = ubx['_userbox-r']local render = ubx.renderlocal categories = ubx.categories
---------------------------------------------------------------------------------- Helper functions--------------------------------------------------------------------------------
local function inTag(s, tag) -- Makes a pattern that tests whether s is inside a given html tag. return '<' .. tag .. ' [^>]-' .. send
local function inAttr(s, attr) -- Makes a pattern that tests whether s is inside a given html attribute. return attr .. '="[^"]-' .. send
local function inTagAttr(s, tag, attr) -- Makes a pattern that tests whether s is inside a given html tag -- and a given html attribute. return inTag(inAttr(s, attr), tag)end
local function renderId(data) data.showId = true return render(data)end
local function renderId2(data) data.showId2 = true return render(data)end
---------------------------------------------------------------------------------- Render tests--------------------------------------------------------------------------------
function suite:testRenderFloat self:assertStringContains(inTagAttr('float:right', 'div', 'style'), render)end
function suite:testRenderBorder self:assertStringContains(inTagAttr('border:5px', 'div', 'style'), render) self:assertStringContains('solid red', render)end
function suite:testRenderMargin self:assertStringContains(inTagAttr('margin:1px', 'div', 'style'), render)end
function suite:testRenderWidth self:assertStringContains(inTagAttr('width:120px', 'div', 'style'), render)end
function suite:testRenderUserboxClass self:assertStringContains(inTagAttr('wikipediauserbox', 'div', 'class'), render)end
function suite:testRenderBodyClass self:assertStringContains(inTagAttr('foobar', 'div', 'class'), render)end
function suite:testRenderBorderCollapse self:assertStringContains(inTagAttr('border-collapse:collapse', 'table', 'style'), render)end
function suite:testRenderBorderCollapse self:assertStringContains(inTagAttr('width:120px', 'table', 'style'), render)end
function suite:testRenderTableWidth self:assertStringContains(inTagAttr('width:120px', 'table', 'style'), render)end
function suite:testRenderMarginBottom self:assertStringContains(inTagAttr('margin%-bottom:0', 'table', 'style'), render)end
function suite:testRenderBackgroundColor self:assertStringContains(inTagAttr('background:red', 'table', 'style'), render)end
---------------------------------------------------------------------------------- Render id tests--------------------------------------------------------------------------------
function suite:testRenderIdBorder self:assertStringContains(inTagAttr('border:0', 'td', 'style'), renderId)end
function suite:testRenderIdWidth self:assertStringContains(inTagAttr('width:50px', 'td', 'style'), renderId)end
function suite:testRenderIdHeight self:assertStringContains(inTagAttr('height:50px', 'td', 'style'), renderId)end
function suite:testRenderIdBackgroundColor self:assertStringContains(inTagAttr('background:red', 'td', 'style'), renderId)end
function suite:testRenderIdTextAlign self:assertStringContains(inTagAttr('text%-align:center', 'td', 'style'), renderId)end
function suite:testRenderIdFontSize self:assertStringContains(inTagAttr('font%-size:16pt', 'td', 'style'), renderId)end
function suite:testRenderIdColor self:assertStringContains(inTagAttr('color:blue', 'td', 'style'), renderId)end
function suite:testRenderIdPadding self:assertStringContains(inTagAttr('padding:3px', 'td', 'style'), renderId)end
function suite:testRenderIdLineHeight self:assertStringContains(inTagAttr('line%-height:1.5em', 'td', 'style'), renderId)end
function suite:testRenderIdVerticalAlign self:assertStringContains(inTagAttr('vertical%-align:middle', 'td', 'style'), renderId)end
function suite:testRenderIdOtherParams self:assertStringContains(inTagAttr('font%-family:serif', 'td', 'style'), renderId)end
function suite:testRenderIdClass self:assertStringContains(inTagAttr('foobar', 'td', 'class'), renderId)end
function suite:testRenderId self:assertStringContains('
---------------------------------------------------------------------------------- Render info tests--------------------------------------------------------------------------------
function suite:testRenderInfoBorder self:assertStringContains(inTagAttr('border:0', 'td', 'style'), render)end
function suite:testRenderInfoTextAlign self:assertStringContains(inTagAttr('text%-align:center', 'td', 'style'), render)end
function suite:testRenderInfoFontSize self:assertStringContains(inTagAttr('font%-size:16pt', 'td', 'style'), render)end
function suite:testRenderInfoPadding self:assertStringContains(inTagAttr('padding:3px', 'td', 'style'), render)end
function suite:testRenderInfoHeight self:assertStringContains(inTagAttr('height:50px', 'td', 'style'), render)end
function suite:testRenderInfoLineHeight self:assertStringContains(inTagAttr('line%-height:1.5em', 'td', 'style'), render)end
function suite:testRenderInfoColor self:assertStringContains(inTagAttr('color:blue', 'td', 'style'), render)end
function suite:testRenderInfoVerticalAlign self:assertStringContains(inTagAttr('vertical%-align:middle', 'td', 'style'), render)end
function suite:testRenderInfoOtherParams self:assertStringContains(inTagAttr('font%-family:serif', 'td', 'style'), render)end
function suite:testRenderInfoClass self:assertStringContains(inTagAttr('foobar', 'td', 'class'), render)end
function suite:testRenderInfo self:assertStringContains('
---------------------------------------------------------------------------------- Render id2 tests--------------------------------------------------------------------------------
function suite:testRenderId2Border self:assertStringContains(inTagAttr('border:0', 'td', 'style'), renderId2)end
function suite:testRenderId2Width self:assertStringContains(inTagAttr('width:50px', 'td', 'style'), renderId2)end
function suite:testRenderId2Height self:assertStringContains(inTagAttr('height:50px', 'td', 'style'), renderId2)end
function suite:testRenderId2BackgroundColor self:assertStringContains(inTagAttr('background:red', 'td', 'style'), renderId2)end
function suite:testRenderId2TextAlign self:assertStringContains(inTagAttr('text%-align:center', 'td', 'style'), renderId2)end
function suite:testRenderId2FontSize self:assertStringContains(inTagAttr('font%-size:16pt', 'td', 'style'), renderId2)end
function suite:testRenderId2Color self:assertStringContains(inTagAttr('color:blue', 'td', 'style'), renderId2)end
function suite:testRenderId2Padding self:assertStringContains(inTagAttr('padding:3px', 'td', 'style'), renderId2)end
function suite:testRenderId2LineHeight self:assertStringContains(inTagAttr('line%-height:1.5em', 'td', 'style'), renderId2)end
function suite:testRenderId2VerticalAlign self:assertStringContains(inTagAttr('vertical%-align:middle', 'td', 'style'), renderId2)end
function suite:testRenderId2OtherParams self:assertStringContains(inTagAttr('font%-family:serif', 'td', 'style'), renderId2)end
function suite:testRenderId2 self:assertStringContains('
---------------------------------------------------------------------------------- Userbox div and table tag tests--------------------------------------------------------------------------------
function suite:testUserboxFloat self:assertEquals('left', userbox.float) self:assertEquals('right', userbox.float)end
function suite:testUserboxBorderWidth self:assertEquals('1px', userbox.borderWidth) self:assertEquals('2px', userbox.borderWidth) self:assertEquals('3px', userbox.borderWidth)end
function suite:testUserboxBorderColor self:assertEquals('#999', userbox.borderColor) self:assertEquals('red', userbox.borderColor) self:assertEquals('yellow', userbox.borderColor) self:assertEquals('blue', userbox.borderColor) self:assertEquals('green', userbox.borderColor)end
function suite:testUserboxWidth self:assertEquals('238px', userbox.width) self:assertEquals('236px', userbox.width)end
function suite:testUserboxBodyClass self:assertEquals(nil, userbox.bodyClass) self:assertEquals('foobar', userbox.bodyClass)end
function suite:testUserboxBackgroundColor self:assertEquals('#eee', userbox.backgroundColor) self:assertEquals('red', userbox.backgroundColor) self:assertEquals('yellow', userbox.backgroundColor) self:assertEquals('blue', userbox.backgroundColor)end
---------------------------------------------------------------------------------- Userbox id tests--------------------------------------------------------------------------------
function suite:testUserboxId self:assertEquals(nil, userbox.id) self:assertEquals('Id text.', userbox.id) self:assertEquals('More id text.', userbox.id) self:assertEquals('Even more id text.', userbox.id)end
function suite:testUserboxShowId self:assertEquals(true, userbox.showId) self:assertEquals(false, userbox.showId)end
function suite:testUserboxIdWidth self:assertEquals('45px', userbox.idWidth) self:assertEquals('50px', userbox.idWidth) self:assertEquals('55px', userbox.idWidth)end
function suite:testUserboxIdHeight self:assertEquals('45px', userbox.idHeight) self:assertEquals('50px', userbox.idHeight) self:assertEquals('55px', userbox.idHeight)end
function suite:testUserboxIdBackgroundColor self:assertEquals('#ddd', userbox.idBackgroundColor) self:assertEquals('red', userbox.idBackgroundColor) self:assertEquals('yellow', userbox.idBackgroundColor) self:assertEquals('blue', userbox.idBackgroundColor)end
function suite:testUserboxIdTextAlign self:assertEquals('center', userbox.idTextAlign) self:assertEquals('right', userbox.idTextAlign)end
function suite:testUserboxIdFontSize self:assertEquals('14pt', userbox.idFontSize) self:assertEquals('16pt', userbox.idFontSize) self:assertEquals('18pt', userbox.idFontSize) self:assertEquals('20pt', userbox.idFontSize)end
function suite:testUserboxIdColor self:assertEquals('black', userbox.idColor) self:assertEquals('red', userbox.idColor) self:assertEquals('blue', userbox.idColor)end
function suite:testUserboxIdPadding self:assertEquals('0 1px 0 0', userbox.idPadding) self:assertEquals('1px 1px 1px 1px', userbox.idPadding) self:assertEquals('2px 2px 2px 2px', userbox.idPadding)end
function suite:testUserboxIdLineHeight self:assertEquals('1.25em', userbox.idLineHeight) self:assertEquals('1.5em', userbox.idLineHeight) self:assertEquals('1.75em', userbox.idLineHeight)end
function suite:testUserboxIdOtherParams self:assertEquals(nil, userbox.idOtherParams) self:assertEquals('font-family:serif', userbox.idOtherParams) self:assertEquals('font-family:times', userbox.idOtherParams)end
function suite:testUserboxIdClass self:assertEquals(nil, userbox.idClass) self:assertEquals('foobar', userbox.idClass)end
---------------------------------------------------------------------------------- Userbox info tests--------------------------------------------------------------------------------
function suite:testUserboxInfo self:assertEquals("{{{info}}}
", userbox.info) self:assertEquals('Info text.', userbox.info) self:assertEquals('More info text.', userbox.info)end
function suite:testUserboxInfoTextAlign self:assertEquals('left', userbox.infoTextAlign) self:assertEquals('right', userbox.infoTextAlign)end
function suite:testUserboxInfoFontSize self:assertEquals('8pt', userbox.infoFontSize) self:assertEquals('10pt', userbox.infoFontSize) self:assertEquals('12pt', userbox.infoFontSize)end
function suite:testUserboxInfoHeight self:assertEquals('45px', userbox.infoHeight) self:assertEquals('50px', userbox.infoHeight) self:assertEquals('55px', userbox.infoHeight)end
function suite:testUserboxInfoPadding self:assertEquals('0 4px 0 4px', userbox.infoPadding) self:assertEquals('1px 1px 1px 1px', userbox.infoPadding) self:assertEquals('2px 2px 2px 2px', userbox.infoPadding)end
function suite:testUserboxInfoLineHeight self:assertEquals('1.25em', userbox.infoLineHeight) self:assertEquals('1.5em', userbox.infoLineHeight) self:assertEquals('1.75em', userbox.infoLineHeight)end
function suite:testUserboxInfoColor self:assertEquals('black', userbox.infoColor) self:assertEquals('red', userbox.infoColor) self:assertEquals('blue', userbox.infoColor)end
function suite:testUserboxInfoOtherParams self:assertEquals(nil, userbox.infoOtherParams) self:assertEquals('font-family:serif', userbox.infoOtherParams) self:assertEquals('font-family:times', userbox.infoOtherParams)end
function suite:testUserboxInfoClass self:assertEquals(nil, userbox.infoClass) self:assertEquals('foobar', userbox.infoClass)end
---------------------------------------------------------------------------------- Userbox2 div and table tag tests--------------------------------------------------------------------------------
function suite:testUserbox2Float self:assertEquals('left', userbox2.float) self:assertEquals('right', userbox2.float)end
function suite:testUserbox2BorderWidth self:assertEquals('1px', userbox2.borderWidth) self:assertEquals('2px', userbox2.borderWidth) self:assertEquals('3px', userbox2.borderWidth)end
function suite:testUserbox2BorderColor self:assertEquals('#999999', userbox2.borderColor) self:assertEquals('red', userbox2.borderColor) self:assertEquals('blue', userbox2.borderColor) self:assertEquals('green', userbox2.borderColor)end
function suite:testUserbox2Width self:assertEquals('238px', userbox2.width)end
function suite:testUserbox2BodyClass self:assertEquals(nil, userbox2.bodyClass) self:assertEquals('foobar', userbox2.bodyClass)end
function suite:testUserbox2BackgroundColor self:assertEquals('#eeeeee', userbox2.backgroundColor) self:assertEquals('yellow', userbox2.backgroundColor) self:assertEquals('blue', userbox2.backgroundColor)end
---------------------------------------------------------------------------------- Userbox2 id tests--------------------------------------------------------------------------------
function suite:testUserbox2Id self:assertEquals('id1', userbox2.id) self:assertEquals('Id text.', userbox2.id) self:assertEquals('More id text.', userbox2.id) self:assertEquals('Even more id text.', userbox2.id)endfunction suite:testUserbox2ShowId self:assertEquals(true, userbox2.showId)end
function suite:testUserbox2IdWidth self:assertEquals('45px', userbox2.idWidth) self:assertEquals('50px', userbox2.idWidth)end
function suite:testUserbox2IdHeight self:assertEquals('45px', userbox2.idHeight) self:assertEquals('50px', userbox2.idHeight)end
function suite:testUserbox2IdBackgroundColor self:assertEquals('#dddddd', userbox2.idBackgroundColor) self:assertEquals('yellow', userbox2.idBackgroundColor) self:assertEquals('blue', userbox2.idBackgroundColor)end
function suite:testUserbox2IdTextAlign self:assertEquals('center', userbox2.idTextAlign)end
function suite:testUserbox2IdFontSize self:assertEquals('14pt', userbox2.idFontSize) self:assertEquals('16pt', userbox2.idFontSize)end
function suite:testUserbox2IdLineHeight self:assertEquals('1.25em', userbox2.idLineHeight) self:assertEquals('1.5em', userbox2.idLineHeight)end
function suite:testUserbox2IdColor self:assertEquals('black', userbox2.idColor) self:assertEquals('blue', userbox2.idColor)end
function suite:testUserbox2IdPadding self:assertEquals('0 1px 0 0', userbox2.idPadding) self:assertEquals('1px 1px 1px 1px', userbox2.idPadding)end
function suite:testUserbox2IdOtherParams self:assertEquals(nil, userbox2.idOtherParams) self:assertEquals('font-family:times', userbox2.idOtherParams)end
---------------------------------------------------------------------------------- Userbox2 info tests--------------------------------------------------------------------------------
function suite:testUserbox2Info self:assertEquals("{{{info}}}
", userbox2.info) self:assertEquals('Info text.', userbox2.info) self:assertEquals('More info text.', userbox2.info)end
function suite:testUserbox2InfoTextAlign self:assertEquals('left', userbox2.infoTextAlign) self:assertEquals('right', userbox2.infoTextAlign)end
function suite:testUserbox2InfoFontSize self:assertEquals('8pt', userbox2.infoFontSize) self:assertEquals('10pt', userbox2.infoFontSize)end
function suite:testUserbox2InfoColor self:assertEquals('black', userbox2.infoColor) self:assertEquals('red', userbox2.infoColor) self:assertEquals('blue', userbox2.infoColor)end
function suite:testUserbox2InfoPadding self:assertEquals('0 4px 0 4px', userbox2.infoPadding) self:assertEquals('1px 1px 1px 1px', userbox2.infoPadding)end
function suite:testUserbox2InfoLineHeight self:assertEquals('1.25em', userbox2.infoLineHeight) self:assertEquals('1.5em', userbox2.infoLineHeight)end
function suite:testUserbox2InfoOtherParams self:assertEquals(nil, userbox2.infoOtherParams) self:assertEquals('font-family:times', userbox2.infoOtherParams)end
---------------------------------------------------------------------------------- Userbox2 id2 tests--------------------------------------------------------------------------------
function suite:testUserbox2Id2 self:assertEquals('id2', userbox2.id2) self:assertEquals('Id2 text.', userbox2.id2) self:assertEquals('More id2 text.', userbox2.id2) self:assertEquals('Even more id2 text.', userbox2.id2)end
function suite:testUserbox2ShowId2 self:assertEquals(true, userbox2.showId2)end
function suite:testUserbox2Id2Width self:assertEquals('45px', userbox2.id2Width) self:assertEquals('50px', userbox2.id2Width)end
function suite:testUserbox2Id2Height self:assertEquals('45px', userbox2.id2Height) self:assertEquals('50px', userbox2.id2Height)end
function suite:testUserbox2Id2BackgroundColor self:assertEquals('#dddddd', userbox2.id2BackgroundColor) self:assertEquals('yellow', userbox2.id2BackgroundColor) self:assertEquals('blue', userbox2.id2BackgroundColor) self:assertEquals('red', userbox2.id2BackgroundColor)end
function suite:testUserbox2Id2TextAlign self:assertEquals('center', userbox2.id2TextAlign)end
function suite:testUserbox2Id2FontSize self:assertEquals('14pt', userbox2.id2FontSize) self:assertEquals('16pt', userbox2.id2FontSize)end
function suite:testUserbox2Id2LineHeight self:assertEquals('1.25em', userbox2.id2LineHeight) self:assertEquals('1.5em', userbox2.id2LineHeight)end
function suite:testUserbox2Id2Color self:assertEquals('black', userbox2.id2Color) self:assertEquals('blue', userbox2.id2Color)end
function suite:testUserbox2Id2Padding self:assertEquals('0 0 0 1px', userbox2.id2Padding) self:assertEquals('1px 1px 1px 1px', userbox2.id2Padding)end
function suite:testUserbox2Id2OtherParams self:assertEquals(nil, userbox2.id2OtherParams) self:assertEquals('font-family:times', userbox2.id2OtherParams)end
---------------------------------------------------------------------------------- Userboxr div and table tag tests--------------------------------------------------------------------------------
function suite:testUserboxrFloat self:assertEquals('left', userboxr.float) self:assertEquals('right', userboxr.float)end
function suite:testUserboxrBorderWidth self:assertEquals('1px', userboxr.borderWidth) self:assertEquals('2px', userboxr.borderWidth) self:assertEquals('3px', userboxr.borderWidth)end
function suite:testUserboxrBorderColor self:assertEquals('#999', userboxr.borderColor) self:assertEquals('red', userboxr.borderColor) self:assertEquals('yellow', userboxr.borderColor) self:assertEquals('blue', userboxr.borderColor) self:assertEquals('green', userboxr.borderColor)end
function suite:testUserboxrWidth self:assertEquals('238px', userboxr.width)end
function suite:testUserboxrBodyClass self:assertEquals(nil, userboxr.bodyClass) self:assertEquals('foobar', userboxr.bodyClass)end
function suite:testUserboxrBackgroundColor self:assertEquals('#eee', userboxr.backgroundColor) self:assertEquals('red', userboxr.backgroundColor) self:assertEquals('yellow', userboxr.backgroundColor) self:assertEquals('blue', userboxr.backgroundColor)end
---------------------------------------------------------------------------------- Userboxr info tests--------------------------------------------------------------------------------
function suite:testUserboxrInfo self:assertEquals("{{{info}}}
", userboxr.info) self:assertEquals('Info text.', userboxr.info) self:assertEquals('More info text.', userboxr.info)endfunction suite:testUserboxrInfoTextAlign self:assertEquals('left', userboxr.infoTextAlign) self:assertEquals('right', userboxr.infoTextAlign) self:assertEquals('center', userboxr.infoTextAlign)end
function suite:testUserboxrInfoFontSize self:assertEquals('8pt', userboxr.infoFontSize) self:assertEquals('10pt', userboxr.infoFontSize) self:assertEquals('12pt', userboxr.infoFontSize)end
function suite:testUserboxrInfoPadding self:assertEquals('0 4px 0 4px', userboxr.infoPadding) self:assertEquals('1px 1px 1px 1px', userboxr.infoPadding) self:assertEquals('2px 2px 2px 2px', userboxr.infoPadding)end
function suite:testUserboxrInfoLineHeight self:assertEquals('1.25em', userboxr.infoLineHeight) self:assertEquals('1.5em', userboxr.infoLineHeight) self:assertEquals('1.75em', userboxr.infoLineHeight)end
function suite:testUserboxrInfoColor self:assertEquals('black', userboxr.infoColor) self:assertEquals('red', userboxr.infoColor) self:assertEquals('blue', userboxr.infoColor)end
function suite:testUserboxrInfoOtherParams self:assertEquals(nil, userboxr.infoOtherParams) self:assertEquals('font-family:serif', userboxr.infoOtherParams) self:assertEquals('font-family:times', userboxr.infoOtherParams)end
---------------------------------------------------------------------------------- Userboxr id2 tests--------------------------------------------------------------------------------
function suite:testUserboxrId2 self:assertEquals('id', userboxr.id2) self:assertEquals('Id text.', userboxr.id2) self:assertEquals('More id text.', userboxr.id2) self:assertEquals('Even more id text.', userboxr.id2)end
function suite:testUserboxrShowId self:assertEquals(true, userboxr.showId2)end
function suite:testUserboxrId2Width self:assertEquals('45px', userboxr.id2Width) self:assertEquals('50px', userboxr.id2Width) self:assertEquals('55px', userboxr.id2Width)end
function suite:testUserboxrId2Height self:assertEquals('45px', userboxr.id2Height) self:assertEquals('50px', userboxr.id2Height) self:assertEquals('55px', userboxr.id2Height)end
function suite:testUserboxrId2BackgroundColor self:assertEquals('#ddd', userboxr.id2BackgroundColor) self:assertEquals('red', userboxr.id2BackgroundColor) self:assertEquals('yellow', userboxr.id2BackgroundColor) self:assertEquals('blue', userboxr.id2BackgroundColor)end
function suite:testUserboxrId2TextAlign self:assertEquals('center', userboxr.id2TextAlign) self:assertEquals('right', userboxr.id2TextAlign)end
function suite:testUserboxrId2FontSize self:assertEquals('14pt', userboxr.id2FontSize) self:assertEquals('16pt', userboxr.id2FontSize) self:assertEquals('18pt', userboxr.id2FontSize) self:assertEquals('20pt', userboxr.id2FontSize)end
function suite:testUserboxrId2Color self:assertEquals('black', userboxr.id2Color) self:assertEquals('red', userboxr.id2Color) self:assertEquals('blue', userboxr.id2Color)end
function suite:testUserboxrId2Padding self:assertEquals('0 0 0 1px', userboxr.id2Padding) self:assertEquals('1px 1px 1px 1px', userboxr.id2Padding) self:assertEquals('2px 2px 2px 2px', userboxr.id2Padding)end
function suite:testUserboxrId2LineHeight self:assertEquals('1.25em', userboxr.id2LineHeight) self:assertEquals('1.5em', userboxr.id2LineHeight) self:assertEquals('1.75em', userboxr.id2LineHeight)end
function suite:testUserboxrId2OtherParams self:assertEquals(nil, userboxr.id2OtherParams) self:assertEquals('font-family:serif', userboxr.id2OtherParams) self:assertEquals('font-family:times', userboxr.id2OtherParams)end
---------------------------------------------------------------------------------- Categories tests--------------------------------------------------------------------------------
local function mainspaceCats(args) return categories(args, 'Foo')end
local function templateCats(args) return categories(args, 'Template:Edit protected')end
local function userCats(args) return categories(args, 'User:Example')end
local function templateSubpageCats(args) return categories(args, 'Template:Edit protected/sandbox')end
local function userSubpageCats(args) return categories(args, 'User:Example/Lipsum')end
local userBasepage = 'Example'local templateBasepage = 'Edit protected'
function suite:testUserCategories self:assertEquals('', userCats) self:assertEquals('', userCats) self:assertEquals('', userCats)end
function suite:testTemplateCategories self:assertEquals('', templateCats) self:assertEquals('', templateCats) self:assertEquals('', templateCats)end
function suite:testMultipleUserCategories self:assertEquals('', userCats )end
function suite:testMultipleTemplateCategories self:assertEquals('' .. '' .. '', templateCats )end
function suite:testNocat self:assertEquals(nil, userCats) self:assertEquals(nil, templateCats)end
function suite:testNoCategories self:assertEquals(, userCats) self:assertEquals(, templateCats)end
function suite:testUserCategorySubpages self:assertEquals('', userSubpageCats) self:assertEquals('', userCats)end
function suite:testTemplateCategorySubpages self:assertEquals('', templateSubpageCats) self:assertEquals('', templateCats)end
function suite:testUserCategoryNoSubpages self:assertEquals(nil, userSubpageCats) self:assertEquals('', userCats)end
function suite:testTemplateCategoryNoSubpages self:assertEquals(nil, templateSubpageCats) self:assertEquals('', templateCats)end
function suite:assertHasContrastCat(args, title, yes) local oldTitle = mw.title.getCurrentTitle mw.title.getCurrentTitle = function return mw.title.new(title) end local data = userbox(args) local output = render(data) mw.title.getCurrentTitle = oldTitle if yes then self:assertStringContains("", output, true) else self:assertNotStringContains("", output, true) endendfunction suite:testInfoContrastTemplate self:assertHasContrastCat("Template:Foo", true) self:assertHasContrastCat("Template:Foo", false)end
function suite:testInfoContrastUser self:assertHasContrastCat("User:Foo", false) self:assertHasContrastCat("User:Foo", false)end
function suite:testInfoContrastUserSubpage self:assertHasContrastCat("User:Foo/bar", true) self:assertHasContrastCat("User:Foo/bar", false)end
function suite:testIdContrastTemplate self:assertHasContrastCat("Template:Foo", true) self:assertHasContrastCat("Template:Foo", false)end
function suite:testIdContrastUser self:assertHasContrastCat("User:Foo", false) self:assertHasContrastCat("User:Foo", false)end
function suite:testIdContrastUserSubpage self:assertHasContrastCat("User:Foo/bar", true) self:assertHasContrastCat("User:Foo/bar", false)end
function suite:testMainspaceCategory self:assertEquals('', mainspaceCats)end
return suite