Module:Protection banner/config/testcases

This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 23:35, 4 March 2014 (add move disputes). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Unit tests for [[Module:Protection banner]]. Click talk page to run tests.

local pp = require('Module:User:Mr. Stradivarius/pp')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()

--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------

function suite:assertCategoryEquals(expected, protType, protLevel, namespace, reason, expiry)
	local actual = pp.getCategoryName(nil, protType, protLevel, namespace, reason, expiry)
	self:assertEquals(expected, actual)
end

--------------------------------------------------------------------------------
-- Default values
--------------------------------------------------------------------------------

local timestamp = 'July 17, 2020'

--------------------------------------------------------------------------------
-- Category name tests
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- Categories: edit-semi-dispute
--------------------------------------------------------------------------------

function suite:testCategory_edit_semi_main_dispute_all()
	self:assertCategoryEquals('Wikipedia pages semi-protected due to dispute', 'edit', 'semi', 0, 'dispute', nil)
end

function suite:testCategory_edit_semi_talk_dispute_all()
	self:assertCategoryEquals('Wikipedia pages semi-protected due to dispute', 'edit', 'semi', 1, 'dispute', nil)
end

function suite:testCategory_edit_semi_file_dispute_all()
	self:assertCategoryEquals('Wikipedia pages semi-protected due to dispute', 'edit', 'semi', 6, 'dispute', nil)
end

function suite:testCategory_edit_semi_template_dispute_all()
	self:assertCategoryEquals('Wikipedia pages semi-protected due to dispute', 'edit', 'semi', 10, 'dispute', nil)
end

function suite:testCategory_edit_semi_main_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages semi-protected due to dispute', 'edit', 'semi', 0, 'dispute', timestamp)
end

function suite:testCategory_edit_semi_talk_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages semi-protected due to dispute', 'edit', 'semi', 1, 'dispute', timestamp)
end

function suite:testCategory_edit_semi_file_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages semi-protected due to dispute', 'edit', 'semi', 6, 'dispute', timestamp)
end

function suite:testCategory_edit_semi_template_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages semi-protected due to dispute', 'edit', 'semi', 10, 'dispute', timestamp)
end

--------------------------------------------------------------------------------
-- Categories: edit-full-dispute
--------------------------------------------------------------------------------

function suite:testCategory_edit_full_main_dispute_all()
	self:assertCategoryEquals('Wikipedia pages protected due to dispute', 'edit', 'full', 0, 'dispute', nil)
end

function suite:testCategory_edit_full_talk_dispute_all()
	self:assertCategoryEquals('Wikipedia pages protected due to dispute', 'edit', 'full', 1, 'dispute', nil)
end

function suite:testCategory_edit_full_file_dispute_all()
	self:assertCategoryEquals('Wikipedia pages protected due to dispute', 'edit', 'full', 6, 'dispute', nil)
end

function suite:testCategory_edit_full_template_dispute_all()
	self:assertCategoryEquals('Wikipedia pages protected due to dispute', 'edit', 'full', 10, 'dispute', nil)
end

function suite:testCategory_edit_full_main_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages protected due to dispute', 'edit', 'full', 0, 'dispute', timestamp)
end

function suite:testCategory_edit_full_talk_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages protected due to dispute', 'edit', 'full', 1, 'dispute', timestamp)
end

function suite:testCategory_edit_full_file_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages protected due to dispute', 'edit', 'full', 6, 'dispute', timestamp)
end

function suite:testCategory_edit_full_template_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages protected due to dispute', 'edit', 'full', 10, 'dispute', timestamp)
end

--------------------------------------------------------------------------------
-- Categories: move-full-dispute
--------------------------------------------------------------------------------

function suite:testCategory_move_full_template_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages move-protected due to dispute', 'move', 'full', 0, 'dispute', nil)
end

function suite:testCategory_move_full_talk_dispute_all()
	self:assertCategoryEquals('Wikipedia pages move-protected due to dispute', 'move', 'full', 1, 'dispute', nil)
end

function suite:testCategory_move_full_file_dispute_all()
	self:assertCategoryEquals('Wikipedia pages move-protected due to dispute', 'move', 'full', 6, 'dispute', nil)
end

function suite:testCategory_move_full_template_dispute_all()
	self:assertCategoryEquals('Wikipedia pages move-protected due to dispute', 'move', 'full', 10, 'dispute', nil)
end

function suite:testCategory_move_full_main_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages move-protected due to dispute', 'move', 'full', 0, 'dispute', timestamp)
end

function suite:testCategory_move_full_talk_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages move-protected due to dispute', 'move', 'full', 1, 'dispute', timestamp)
end

function suite:testCategory_move_full_file_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages move-protected due to dispute', 'move', 'full', 6, 'dispute', timestamp)
end

function suite:testCategory_move_full_template_dispute_temp()
	self:assertCategoryEquals('Wikipedia pages move-protected due to dispute', 'move', 'full', 10, 'dispute', timestamp)
end


return suite