Module:Lua banner/testcases

local mList = require('Module:List') local mMessageBox = require('Module:Message box')

local p = require('Module:ScribuntoUnit'):new

-- Allow test runner to use both the Module:XXX itself and Module:XXX/sandbox with the same testcases function p:module return self.frame and self.frame.args and self.frame.args.module or 'Lua banner' end

function p:box(text) local boxArgs = { text = text, type = 'notice', small = true, image = '' }	return mMessageBox.main('mbox', boxArgs) end

function p:testRenderBox local mLuaBanner = require('Module:' .. p:module) self:assertEquals(mLuaBanner.renderBox{}, self:box(' Error: no modules specified ')) self:assertEquals(		mLuaBanner.renderBox{'Module:Lua banner'},		self:box('Uses Lua:\n' .. mList.makeList('bulleted', {'Module:Lua banner'}))	) end

function p:testRenderTrackingCategories local mLuaBanner = require('Module:' .. p:module) local moduleTitle = mw.title.new('Module:Lua banner') local templateTitle = mw.title.new('Template:Lua') local templateDocTitle = mw.title.new('Template:Lua/doc') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {}, templateDocTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {'Module:Lua banner'}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {'Module:Lua banner'}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {'Module:Lua banner'}, templateDocTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {'Module:Lua banner', 'Module:String'}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {'Module:Lua banner', 'Module:String'}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {'Module:Lua banner', 'Module:String'}, templateDocTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {'Module:String', 'Module:Lua banner'}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {'Module:String', 'Module:Lua banner'}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({}, {'Module:String', 'Module:Lua banner'}, templateDocTitle), '') end

function p:testRenderTrackingCategoriesWithNocat local mLuaBanner = require('Module:' .. p:module) local moduleTitle = mw.title.new('Module:Lua banner') local templateTitle = mw.title.new('Template:Lua') local templateDocTitle = mw.title.new('Template:Lua/doc') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {}, templateDocTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {'Module:Lua banner'}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {'Module:Lua banner'}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {'Module:Lua banner'}, templateDocTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {'Module:Lua banner', 'Module:String'}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {'Module:Lua banner', 'Module:String'}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {'Module:Lua banner', 'Module:String'}, templateDocTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {'Module:String', 'Module:Lua banner'}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {'Module:String', 'Module:Lua banner'}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({nocat='true'}, {'Module:String', 'Module:Lua banner'}, templateDocTitle), '') end

function p:testRenderTrackingCategoriesWithCategory local mLuaBanner = require('Module:' .. p:module) local moduleTitle = mw.title.new('Module:Lua banner') local templateTitle = mw.title.new('Template:Lua') local templateDocTitle = mw.title.new('Template:Lua/doc') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {}, templateDocTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {'Module:Lua banner'}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {'Module:Lua banner'}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {'Module:Lua banner'}, templateDocTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {'Module:Lua banner', 'Module:String'}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {'Module:Lua banner', 'Module:String'}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {'Module:Lua banner', 'Module:String'}, templateDocTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {'Module:String', 'Module:Lua banner'}, moduleTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {'Module:String', 'Module:Lua banner'}, templateTitle), '') self:assertEquals(mLuaBanner.renderTrackingCategories({category='catname'}, {'Module:String', 'Module:Lua banner'}, templateDocTitle), '') end

return p