Jump to content

Module:Television episode redirect handler/testcases

From Wikipedia, the free encyclopedia
-- Unit tests for [[Module:Television episode redirect handler]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_01_redirect_categories()
	self:preprocess_equals_sandbox_many('{{#invoke:Television episode redirect handler', 'main|test=yes', {
		{"series_name=Arrow (TV series)|season_num=5|episode_num=6", "R from television episode, R to anchor, R with possibilities, R printworthy"},
		{"restricted=yes", "R from television episode, R restricted, R to anchor, R with possibilities, R printworthy"},		
		{"birth_name=yes", "R from television episode, R from birth name, R to anchor, R printworthy"},
		{"alt_name=yes", "R from television episode, R from alternative name, R to anchor, R printworthy"},
		{"former_name=yes", "R from television episode, R from former name, R to anchor, R printworthy"},
		{"short_name=yes", "R from television episode, R from short name, R to anchor, R printworthy"},
		{"long_name=yes", "R from television episode, R from long name, R to anchor, R printworthy"},
		{"title_name=yes", "R from television episode, R from name with title, R to anchor, R unprintworthy"},
		{"alt_spelling=yes", "R from television episode, R from alternative spelling, R to anchor, R unprintworthy"},
		{"to_diacritic=yes", "R from television episode, R to diacritic, R to anchor, R unprintworthy"},
		{"incorrect_name=yes", "R from television episode, R from incorrect name, R to anchor, R unprintworthy"},
		{"capitalisation=yes", "R from television episode, R from miscapitalisation, R to anchor, R unprintworthy"},
		{"unneeded_dab=yes", "R from television episode, R from unnecessary disambiguation, R to anchor, R unprintworthy"},
		{"primary=yes", "R from television episode, R to anchor, R avoided double redirect, R printworthy"},
		{"merge=yes", "R from television episode, R to anchor, R from merge, R with possibilities, R printworthy"},
		{"history=yes", "R from television episode, R to anchor, R with history, R with possibilities, R printworthy"},
		{"draft_move=yes", "R from television episode, R from move, R from draft namespace, R to anchor, R unprintworthy"},
	})
end

function p:test_02_title_handling()
	self:preprocess_equals_sandbox_many('{{#invoke:Television episode redirect handler', 'main|test=yes', {
		{"test_title=Guilty", "R from television episode, R to anchor, R with Wikidata item, R with possibilities, R printworthy"},
		{"test_title=Guilty (episode)", "R from television episode, R from incorrect disambiguation, R to anchor, R unprintworthy"},
		{"test_title=Guilty (Arrow)|correct_disambiguation=Arrow", "R from television episode, R to anchor, R with possibilities, R printworthy"},
		{"test_title=Guilty (Arrow episode)|correct_disambiguation=Arrow", "R from television episode, R to anchor, R with possibilities, R printworthy"},
	})
end

function p:test_03_title_section_handling()
	self:preprocess_equals_sandbox_many('{{#invoke:Television episode redirect handler', 'main|test=yes', {
		{"", "R from television episode, R to anchor, R with possibilities, R printworthy"},
		{"anchor=yes", "R from television episode, R to anchor, R with possibilities, R printworthy"},
		{"section=test", "R from television episode, R to section, R with possibilities, R printworthy"},
		{"list=test", "R from television episode, R to list entry, R with possibilities, R printworthy"},
		{"to_article=test", "R from television episode, R with possibilities, R printworthy"},
	})
end

function p:test_04_multi_series()
	self:preprocess_equals_sandbox_many('{{#invoke:Television episode redirect handler', 'main|test=yes', {
		{"series_name=Arrow (TV series)|series_name2=The Flash (TV series)", "Arrow (TV series), The Flash (TV series), R from television episode, R to anchor, R with possibilities, R printworthy"},
		{"series_name=Arrow (TV series)|series_name2=The Flash (TV series)|series_name3=Supergirl (TV series)", "Arrow (TV series), The Flash (TV series), Supergirl (TV series), R from television episode, R to anchor, R with possibilities, R printworthy"},
	})
end

return p