Jump to content

Module:Television episode short description/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Gonnym (talk | contribs) at 16:15, 17 January 2020. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Unit tests for [[Module:Television episode short description]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_1_1_descriptions_live()
	self:preprocess_equals_many('{{#invoke:Television episode short description|getShortDescription|test=yes|', '}}', {
		{'', 'A television episode'},
		{'series_name=Lost', 'An episode of \'\'Lost\'\''},
		{'series_name=Lost|season_num=1', 'An episode of the first season of \'\'Lost\'\''},
		{'series_name=Lost|season_num=5|episode_num=4', '4th episode of the fifth season of \'\'Lost\'\''},
		{'series_name=Firefly|season_num=1|season_num_uk=2|episode_num=1', '1st episode of the first season of \'\'Firefly\'\''},
		{'series_name=Firefly|season_num_uk=2|episode_num=1', '1st episode of the second season of \'\'Firefly\'\''},
		{'series_name=Randall and Hopkirk (Deceased)|season_num=1|episode_num=1|not_dab=yes', '1st episode of the first season of \'\'Randall and Hopkirk (Deceased)\'\''},
		{'series_name=Lost|special=yes', 'A special episode of \'\'Lost\'\''},
		{'series_name=Lost|special=recap', 'A recap episode of \'\'Lost\'\''},
		{'series_name=Lost|single_season=yes|episode_num=4', '4th episode of \'\'Lost\'\''},
		{'series_name=Lost|single_season=yes|episode_num=4, 5|multi_episode=yes', '4th and 5th episodes of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_1_2_descriptions_sandbox()
	self:preprocess_equals_many('{{#invoke:Television episode short description/sandbox|getShortDescription|test=yes|', '}}', {
		{'', 'A television episode'},
		{'series_name=Lost', 'An episode of \'\'Lost\'\''},
		{'series_name=Lost|season_num=1', 'An episode of the first season of \'\'Lost\'\''},
		{'series_name=Lost|season_num=5|episode_num=4', '4th episode of the fifth season of \'\'Lost\'\''},
		{'series_name=Firefly|season_num=1|season_num_uk=2|episode_num=1', '1st episode of the first season of \'\'Firefly\'\''},
		{'series_name=Firefly|season_num_uk=2|episode_num=1', '1st episode of the second season of \'\'Firefly\'\''},
		{'series_name=Randall and Hopkirk (Deceased)|season_num=1|episode_num=1|not_dab=yes', '1st episode of the first season of \'\'Randall and Hopkirk (Deceased)\'\''},
		{'series_name=Lost|special=yes', 'A special episode of \'\'Lost\'\''},
		{'series_name=Lost|special=recap', 'A recap episode of \'\'Lost\'\''},
		{'series_name=Lost|single_season=yes|episode_num=4', '4th episode of \'\'Lost\'\''},
		{'series_name=Lost|single_season=yes|episode_num=4, 5|multi_episode=yes', '4th and 5th episodes of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_2_1_multi_part_episode_yes_value_live()
	self:preprocess_equals_many('{{#invoke:Television episode short description|getShortDescription|test=yes|series_name=Lost|season_num=3|multi_episodes=yes|', '}}', {
		{'episode_num=22 and 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22 / 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22, 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22 & 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22 - 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22 - 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_2_2_multi_part_episode_yes_value_sandbox()
	self:preprocess_equals_many('{{#invoke:Television episode short description/sandbox|getShortDescription|test=yes|series_name=Lost|season_num=3|multi_episodes=yes|', '}}', {
		{'episode_num=22 and 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22 / 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22, 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22 & 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22 - 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'episode_num=22 - 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_2_3_multi_part_number_value_episode_live()
	self:preprocess_equals_many('{{#invoke:Television episode short description|getShortDescription|test=yes|series_name=Lost|season_num=3|', '}}', {
		{'multi_episodes=1|episode_num=22', '22nd episode of the third season of \'\'Lost\'\''},
		{'multi_episodes=2|episode_num=22, 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'multi_episodes=3|episode_num=22, 23, 24', '22nd, 23rd and 24th episodes of the third season of \'\'Lost\'\''},
		{'multi_episodes=4|episode_num=22, 23, 24, 25', '22nd, 23rd, 24th and 25th episodes of the third season of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_2_4_multi_part_number_value_episode_sandbox()
	self:preprocess_equals_many('{{#invoke:Television episode short description/sandbox|getShortDescription|test=yes|series_name=Lost|season_num=3|', '}}', {
		{'multi_episodes=1|episode_num=22', '22nd episode of the third season of \'\'Lost\'\''},
		{'multi_episodes=2|episode_num=22, 23', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
		{'multi_episodes=3|episode_num=22, 23, 24', '22nd, 23rd and 24th episodes of the third season of \'\'Lost\'\''},
		{'multi_episodes=4|episode_num=22, 23, 24, 25', '22nd, 23rd, 24th and 25th episodes of the third season of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_3_1_link_test_live()
	self:preprocess_equals_many('{{#invoke:Television episode short description|getShortDescription|test=yes|', '}}', {
		{'series_name=[[Lost]]', 'An episode of \'\'Lost\'\''},
		{'series_name=[[Firefly (TV series)|Firefly]]|season_num=1|episode_num=1', '1st episode of the first season of \'\'Firefly\'\''},
		{'series_name=[[Firefly (TV series)|Firefly]]|season_num=1|season_num_uk=2|episode_num=1', '1st episode of the first season of \'\'Firefly\'\''},
		{'series_name=[[Randall and Hopkirk (Deceased)]]|season_num=1|episode_num=1|not_dab=yes', '1st episode of the first season of \'\'Randall and Hopkirk (Deceased)\'\''},
    }, {nowiki=1})
end

function p:test_3_2_link_test_sandbox()
	self:preprocess_equals_many('{{#invoke:Television episode short description/sandbox|getShortDescription|test=yes|', '}}', {
		{'series_name=[[Lost]]', 'An episode of \'\'Lost\'\''},
		{'series_name=[[Firefly (TV series)|Firefly]]|season_num=1|episode_num=1', '1st episode of the first season of \'\'Firefly\'\''},
		{'series_name=[[Firefly (TV series)|Firefly]]|season_num=1|season_num_uk=2|episode_num=1', '1st episode of the first season of \'\'Firefly\'\''},
		{'series_name=[[Randall and Hopkirk (Deceased)]]|season_num=1|episode_num=1|not_dab=yes', '1st episode of the first season of \'\'Randall and Hopkirk (Deceased)\'\''},
    }, {nowiki=1})
end

function p:test_4_1_decimal_numbers_live()
	self:preprocess_equals_many('{{#invoke:Television episode short description|getShortDescription|test=yes|series_name=Lost|', '}}', {		
		{'season_num=3|episode_num=1.2', '1st episode of the third season of \'\'Lost\'\''},
		{'season_num=3|episode_num=113.22', '113th episode of the third season of \'\'Lost\'\''},
		{'season_num=1.2|episode_num=1.2', '1st episode of the first season of \'\'Lost\'\''},
		{'season_num_uk=1.2|episode_num=1.2', '1st episode of the first season of \'\'Lost\'\''},
		{'season_num=3|episode_num=22.1, 22.2|multi_episodes=yes', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_4_2_decimal_numbers_sandbox()
	self:preprocess_equals_many('{{#invoke:Television episode short description/sandbox|getShortDescription|test=yes|series_name=Lost|', '}}', {		
		{'season_num=3|episode_num=1.2', '1st episode of the third season of \'\'Lost\'\''},
		{'season_num=3|episode_num=113.22', '113th episode of the third season of \'\'Lost\'\''},
		{'season_num=1.2|episode_num=1.2', '1st episode of the first season of \'\'Lost\'\''},
		{'season_num_uk=1.2|episode_num=1.2', '1st episode of the first season of \'\'Lost\'\''},
		{'season_num=3|episode_num=22.1, 22.2|multi_episodes=yes', '22nd and 23rd episodes of the third season of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_5_1_invalid_characters_episode_live()
	self:preprocess_equals_many('{{#invoke:Television episode short description|getShortDescription|test=yes|series_name=Lost|season_num=3|', '}}', {			
		{'episode_num=14<ref>Episode test</ref>', '14th episode of the third season of \'\'Lost\'\''},
		{'episode_num=[[14]]', '14th episode of the third season of \'\'Lost\'\''},
		{'episode_num=[[test|14]]', '14th episode of the third season of \'\'Lost\'\''},
		{'episode_num=<ref>{{cite web |url=http://www.bcdb.com/cartoon/91394-Tricks_And_Treats.html | title=Test ref: season num}} Episode Profile</ref>', 'An episode of the third season of \'\'Lost\'\''},
		{'episode_num=[http://www.bcdb.com/cartoon/11394-Tricks_And_Treats.html]', 'An episode of the third season of \'\'Lost\'\''},
		{'episode_num={{ref|Five|5}}', 'An episode of the third season of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_5_2_invalid_characters_episode_sandbox()
	self:preprocess_equals_many('{{#invoke:Television episode short description/sandbox|getShortDescription|test=yes|series_name=Lost|season_num=3|', '}}', {			
		{'episode_num=14<ref>Episode test</ref>', '14th episode of the third season of \'\'Lost\'\''},
		{'episode_num=[[14]]', '14th episode of the third season of \'\'Lost\'\''},
		{'episode_num=[[test|14]]', '14th episode of the third season of \'\'Lost\'\''},
		{'episode_num=<ref>{{cite web |url=http://www.bcdb.com/cartoon/91394-Tricks_And_Treats.html | title=Test ref: season num}} Episode Profile</ref>', 'An episode of the third season of \'\'Lost\'\''},
		{'episode_num=[http://www.bcdb.com/cartoon/11394-Tricks_And_Treats.html]', 'An episode of the third season of \'\'Lost\'\''},
		{'episode_num={{ref|Five|5}}', 'An episode of the third season of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_6_1_invalid_characters_season_live()
	self:preprocess_equals_many('{{#invoke:Television episode short description|getShortDescription|test=yes|series_name=Lost|episode_num=14|', '}}', {	
		{'season_num=[[3]]', '14th episode of the third season of \'\'Lost\'\''},
		{'season_num=[[test|3]]', '14th episode of the third season of \'\'Lost\'\''},
		{'season_num=<ref>{{cite web |url=http://www.bcdb.com/cartoon/11394-Tricks_And_Treats.html | title=Test ref: season num}} Episode Profile</ref>', 'An episode of \'\'Lost\'\''},
		{'season_num=[http://www.bcdb.com/cartoon/11394-Tricks_And_Treats.html]', 'An episode of \'\'Lost\'\''},
		{'season_num={{ref|Five|5}}', 'An episode of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_6_2_invalid_characters_season_sandbox()
	self:preprocess_equals_many('{{#invoke:Television episode short description/sandbox|getShortDescription|test=yes|series_name=Lost|episode_num=14|', '}}', {	
		{'season_num=[[3]]', '14th episode of the third season of \'\'Lost\'\''},
		{'season_num=[[test|3]]', '14th episode of the third season of \'\'Lost\'\''},
		{'season_num=<ref>{{cite web |url=http://www.bcdb.com/cartoon/11394-Tricks_And_Treats.html | title=Test ref: season num}} Episode Profile</ref>', 'An episode of \'\'Lost\'\''},
		{'season_num=[http://www.bcdb.com/cartoon/11394-Tricks_And_Treats.html]', 'An episode of \'\'Lost\'\''},
		{'season_num={{ref|Five|5}}', 'An episode of \'\'Lost\'\''},
    }, {nowiki=1})
end

function p:test_7_1_invalid_characters_series_live()
	self:preprocess_equals_many('{{#invoke:Television episode short description|getShortDescription|test=yes|season_num=3|episode_num=14|', '}}', {	
		{'series_name=Lost{{ref|Alpha|α}}', '14th episode of the third season of \'\'Lost\'\''},
		{'series_name={{ref|Alpha|α}}', 'A television episode'},
		{'series_name=Lost<ref name="Episode title test">{{cite web|url=http://www.Wikipedia.org|title=Wikipedia}}</ref>', '14th episode of the third season of \'\'Lost\'\''},
		{'series_name=Lost[http://www.Wikipedia.org]', '14th episode of the third season of \'\'Lost\'\''},
		{'series_name=[http://www.Wikipedia.org]', 'A television episode'},
		{'series_name=[http://www.Wikipedia.org]', 'A television episode'}
    }, {nowiki=1})
end

function p:test_7_2_invalid_characters_series_sandbox()
	self:preprocess_equals_many('{{#invoke:Television episode short description/sandbox|getShortDescription|test=yes|season_num=3|episode_num=14|', '}}', {	
		{'series_name=Lost{{ref|Alpha|α}}', '14th episode of the third season of \'\'Lost\'\''},
		{'series_name={{ref|Alpha|α}}', 'A television episode'},
		{'series_name=Lost<ref name="Episode title test">{{cite web|url=http://www.Wikipedia.org|title=Wikipedia}}</ref>', '14th episode of the third season of \'\'Lost\'\''},
		{'series_name=Lost[http://www.Wikipedia.org]', '14th episode of the third season of \'\'Lost\'\''},
		{'series_name=[http://www.Wikipedia.org]', 'A television episode'},
		{'series_name=[http://www.Wikipedia.org]', 'A television episode'}
    }, {nowiki=1})
end

function p:test_8_1_categories_live()
	self:preprocess_equals_many('{{#invoke:Television episode short description|test|test=cat|', '}}', {
		{'', '[[Category:Television episode articles with short description with no series name|Television episode short description/testcases]]'},
		{'series_name=Lost', '[[Category:Television episode articles with short description with no season number|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=1', '[[Category:Television episode articles with short description with no episode number|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=5|episode_num=4', '[[Category:Television episode articles with short description for single episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|episode_num=22 and 23|multi_episodes=yes', '[[Category:Television episode articles with short description for multi-part episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|episode_num=22 and 23|multi_episodes=1', '[[Category:Television episode articles with short description for single episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|episode_num=22 and 23|multi_episodes=2', '[[Category:Television episode articles with short description for multi-part episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|episode_num=22 and 23|multi_episodes=3', '[[Category:Television episode articles with short description for multi-part episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|special=yes|episode_num=22', '[[Category:Television episode articles with short description for single episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|single_season=yes|episode_num=22', '[[Category:Television episode articles with short description for single episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|single_season=yes|episode_num=22 and 23|multi_episodes=yes', '[[Category:Television episode articles with short description for multi-part episodes|Television episode short description/testcases]]'},
    }, {nowiki=1})
end

function p:test_8_2_categories_sandbox()
	self:preprocess_equals_many('{{#invoke:Television episode short description/sandbox|test|test=cat|', '}}', {
		{'', '[[Category:Television episode articles with short description with no series name|Television episode short description/testcases]]'},
		{'series_name=Lost', '[[Category:Television episode articles with short description with no season number|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=1', '[[Category:Television episode articles with short description with no episode number|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=5|episode_num=4', '[[Category:Television episode articles with short description for single episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|episode_num=22 and 23|multi_episodes=yes', '[[Category:Television episode articles with short description for multi-part episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|episode_num=22 and 23|multi_episodes=1', '[[Category:Television episode articles with short description for single episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|episode_num=22 and 23|multi_episodes=2', '[[Category:Television episode articles with short description for multi-part episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|episode_num=22 and 23|multi_episodes=3', '[[Category:Television episode articles with short description for multi-part episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|special=yes|episode_num=22', '[[Category:Television episode articles with short description for single episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|single_season=yes|episode_num=22', '[[Category:Television episode articles with short description for single episodes|Television episode short description/testcases]]'},
		{'series_name=Lost|season_num=3|single_season=yes|episode_num=22 and 23|multi_episodes=yes', '[[Category:Television episode articles with short description for multi-part episodes|Television episode short description/testcases]]'},
    }, {nowiki=1})
end

return p