Module:Infobox television/testcases
| This is the test cases page for the module Module:Infobox television. Results of the test cases. |
-- Unit tests for [[Module:Infobox television]]. Click talk page to run tests.
local p = require('Module:UnitTests')
local categories = {
alt_name = "[[Category:Pages using infobox television with incorrectly formatted values|%s]]",
dates_incorrectly_formatted = "[[Category:Pages using infobox television with nonstandard dates]]",
dates_missing = "[[Category:Pages using infobox television with missing dates]]",
flag_icon = "[[Category:Pages using infobox television with flag icon]]",
image_values_without_an_image = "[[Category:Pages using infobox television with image-related values without an image]]",
incorrectly_formatted = "[[Category:Pages using infobox television with incorrectly formatted values|%s]]",
manual_display_title = "[[Category:Pages using infobox television with unnecessary manual displaytitle]]",
manual_display_title_temp_tracking = "[[Category:Pages using infobox television with manual displaytitle]]",
non_matching_title = "[[Category:Pages using infobox television with non-matching title]]",
unnecessary_title_parameter = "[[Category:Pages using infobox television with unnecessary name parameter]]",
unlinked_values = "[[Category:Pages using infobox television with unlinked values|%s]]",
temp = "[[Category:Temp infobox television tracking category|%s]]",
}
local function expandTemplate(template, value)
local frame = mw.getCurrentFrame()
return frame:expandTemplate{title = template, args = value}
end
local function getCategory(category, parameter)
return string.format(category, parameter)
end
function p:test_01_is_infobox_title_equal_to_article_title()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'page_title_test=Long article title|name=' .. expandTemplate("Nowrap", {"Long article title"}), ''},
{'page_title_test=Long article title|name=Long article <br>title', ''},
{'page_title_test=Long article title|name=Long article <br >title', ''},
{'page_title_test=Long article title|name=Long article <br/>title', ''},
{'page_title_test=Long article title|name=Long article <br />title', ''},
{'page_title_test=Long article title|name=Long article <br/> title', ''},
{'page_title_test=Long article title (dab)|name=' .. expandTemplate("Nowrap", {"Long article title"}), ''},
{'page_title_test=Long article title (dab)|name=Long article <br>title', ''},
{'page_title_test=Title (not dab)|name=' .. expandTemplate("Nowrap", {"Title (not dab)"}), ''},
{'page_title_test=Title (not dab)|name=Title <br>(not dab)', ''},
{'page_title_test=Test|name=Test', categories.unnecessary_title_parameter},
{'page_title_test=Test (not dab)|name=Test (not dab)', categories.unnecessary_title_parameter},
{'page_title_test=Test (dab)|name=Test', categories.unnecessary_title_parameter},
{'page_title_test=Test|name=test', categories.non_matching_title},
{'page_title_test=Long article title|name=' .. expandTemplate("Nowrap", {"Long article Title"}), categories.non_matching_title},
{'page_title_test=Long article title|name=Long article <br/> Title', categories.non_matching_title},
}, {nowiki=1})
end
function p:test_02_has_display_title()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'', ''},
{'page_test=Module:Infobox television/italic test6', categories.manual_display_title}, -- {{Italic title}}
{'page_test=Module:Infobox television/italic test1', categories.manual_display_title}, -- {{Italic}}
{'page_test=Module:Infobox television/italic test2', categories.manual_display_title}, -- {{Italics}}
{'page_test=Module:Infobox television/italic test3', categories.manual_display_title}, -- {{Italictitle}}
{'page_test=Module:Infobox television/italic test4', categories.manual_display_title}, -- {{Italics title}}
{'page_test=Module:Infobox television/italic test5', categories.manual_display_title_temp_tracking}, -- {{DISPLAYTITLE}}
}, {nowiki=1})
end
function p:test_03_are_image_auxiliary_values_used_for_no_image()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'image=test|image_size=1', ''},
{'image_size=1', categories.image_values_without_an_image},
{'image_upright=1', categories.image_values_without_an_image},
{'image_alt=test', categories.image_values_without_an_image},
{'alt=test', categories.image_values_without_an_image},
{'caption=test', categories.image_values_without_an_image},
}, {nowiki=1})
end
function p:test_04_is_image_using_incorrect_syntax()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'image=image.jpg', ''},
{'image=File:image.jpg', getCategory(categories.incorrectly_formatted, 'image')},
{'image=[[File:image.jpg]]', getCategory(categories.incorrectly_formatted, 'image')},
{'image=Image:image.jpg', getCategory(categories.incorrectly_formatted, 'image')},
{'image=[[Image:image.jpg]]', getCategory(categories.incorrectly_formatted, 'image')},
{'image=http://test.com', getCategory(categories.incorrectly_formatted, 'image')},
{'image=https://test.com', getCategory(categories.incorrectly_formatted, 'image')},
}, {nowiki=1})
end
function p:test_05_is_image_size_using_px()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'image=test|image_size=100', ''},
{'image=test|image_size=100px', getCategory(categories.incorrectly_formatted, 'image_size')},
}, {nowiki=1})
end
function p:test_06_is_image_size_using_px()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'image=test|image_size=100', ''},
{'image=test|image_size=100px', getCategory(categories.incorrectly_formatted, 'image_size')},
}, {nowiki=1})
end
-- function p:test_07_is_alt_name_in_italics()
-- self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
-- {'alt_name=Another name', ''},
-- {"alt_name=''another name''", getCategory(categories.incorrectly_formatted, 'alt_name')},
-- -- Single word name
-- {'alt_name=' .. expandTemplate("Plainlist", {"* ''First alt name''\n* ''Second alt name''\n* ''Third alt name''"}), ''},
-- {'alt_name=' .. expandTemplate("Plainlist", {"* First alt name\n* Second alt name\n* Third alt name"}), getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {'alt_name=' .. expandTemplate("Plainlist", {"* ''First alt name''\n* ''Second alt name'' *\nThird alt name"}), getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {'alt_name=' .. expandTemplate("Unbulleted list", {"''First alt name''", "''Second alt name''", "''Third alt name''"}), ''},
-- {'alt_name=' .. expandTemplate("Unbulleted list", {"''First alt name''", "''Second alt name''", "Third alt name"}), getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {"alt_name=''First alt name''<br>''Second alt name''<br>''Third alt name''", ''},
-- {"alt_name=''First alt name''<br>''Second alt name''<br>Third alt name", getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {"alt_name=''First alt name''<br />''Second alt name''<br />Third alt name", getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {"alt_name=''First alt name''<br/>''Second alt name''<br/>Third alt name", getCategory(categories.incorrectly_formatted, 'alt_name')},
-- -- Multi-word names
-- {'alt_name=' .. expandTemplate("Plainlist", {"* ''alt1''\n* ''alt2''\n* ''alt3''"}), ''},
-- {'alt_name=' .. expandTemplate("Plainlist", {"* alt1\n* alt2\n* alt3"}), getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {'alt_name=' .. expandTemplate("Plainlist", {"* ''alt1''\n* ''alt2'' *\nalt3"}), getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {'alt_name=' .. expandTemplate("Unbulleted list", {"''alt1''", "''alt2''", "''alt3''"}), ''},
-- {'alt_name=' .. expandTemplate("Unbulleted list", {"''alt1''", "''alt2''", "alt3"}), getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {"alt_name=''alt1''<br>''alt2''<br>''alt3''", ''},
-- {"alt_name=''alt1''<br>''alt2''<br>alt3", getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {"alt_name=''alt1''<br />''alt2''<br />alt3", getCategory(categories.incorrectly_formatted, 'alt_name')},
-- {"alt_name=''alt1''<br/>''alt2''<br/>alt3", getCategory(categories.incorrectly_formatted, 'alt_name')},
-- }, {nowiki=1})
-- end
function p:test_08_has_flag_icon()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'director=' .. expandTemplate("USA", {}) .. 'test', categories.flag_icon},
}, {nowiki=1})
end
function p:test_09_is_country_name_valid()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'country=United States', ''},
{'country=' .. expandTemplate("Plainlist", {'*France\n*United States'}), ''},
{'country=U.S.A.', getCategory(categories.incorrectly_formatted, 'country')},
{'country=U.S.A', getCategory(categories.incorrectly_formatted, 'country')},
{'country=U.S.', getCategory(categories.incorrectly_formatted, 'country')},
{'country=U.S', getCategory(categories.incorrectly_formatted, 'country')},
{'country=USA', getCategory(categories.incorrectly_formatted, 'country')},
{'country=US', getCategory(categories.incorrectly_formatted, 'country')},
{'country=UK', getCategory(categories.incorrectly_formatted, 'country')},
{'country=U.K.', getCategory(categories.incorrectly_formatted, 'country')},
{'country=' .. expandTemplate("Plainlist", {'*France\n*USA'}), getCategory(categories.incorrectly_formatted, 'country')},
}, {nowiki=1})
end
-- Commented out with revision 1241081163 since there was no consensous on which languages to allow to be linked.
-- function p:test_10_are_values_linked_or_formatted()
-- self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
-- {'language=English', ''},
-- {'language=[[English]]', getCategory(categories.incorrectly_formatted, 'language')},
-- }, {nowiki=1})
-- end
function p:test_11_is_credit_used_correctly()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
-- Valid names
{'producer=John Doe', ''},
{'producer=[[John Doe (executive producer)|John Doe]]', ''},
{'producer=[[John Doe (executive producer)|John Doe]]<br>[[John Doe (executive producer)|John Doe]]', ''},
{'producer=[[Muiris Mac Conghail]]', ''},
{'producer=Caroline<br>Jane Doe', ''},
{'producer=Sabrina Plisco-Morris', ''},
{'writer=Simon Booker', ''},
{'writer=Aulsondro \"Novelist\" Hamilton', ''},
{'writer=[[Jack Trevor Story]]', ''},
{'director=Sanford Bookstaver', ''},
{'director=Tanveer Bookwala', ''},
{'director=Assistant director John Doe', getCategory(categories.incorrectly_formatted, 'director')},
{'producer=John Doe<br>\'\'\'executive\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'producer=John Doe<br>\'\'\'associate\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'producer=John Doe<br>\'\'\'co-producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'producer=John Doe<br>\'\'\'line producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'producer=John Doe<br>\'\'\'supervising producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'producer=John Doe<br>\'\'\'Executive\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'producer=John Doe<br>\'\'\'Associate\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'producer=John Doe<br>\'\'\'Co-producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'producer=John Doe<br>\'\'\'Line producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'producer=John Doe<br>\'\'\'Supervising producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'producer')},
{'executive_producer=John Doe', ''},
{'executive_producer=John Doe<br>\'\'\'executive\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'associate\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'co-producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'line producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'supervising producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'Executive\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'Associate\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'Co-producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'Line producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'Supervising producer\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'executive_producer=John Doe<br>\'\'\'prod.\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'executive_producer')},
{'editor=John Doe', ''},
{'editor=John Doe<br>\'\'\'on-line\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'editor')},
{'editor=John Doe<br>\'\'\'Assistant\'\'\'<br>Jane Doe', getCategory(categories.incorrectly_formatted, 'editor')},
{'screenplay=John Doe', ''},
{'story=John Doe', ''},
{'screenplay=John Doe', ''},
{'teleplay=John Doe', ''},
{'writer=John Doe (screenplay)', getCategory(categories.incorrectly_formatted, 'writer')},
{'writer=John Doe (story)', getCategory(categories.incorrectly_formatted, 'writer')},
{'writer=John Doe (teleplay)', getCategory(categories.incorrectly_formatted, 'writer')},
{'writer=John Doe (script)', getCategory(categories.incorrectly_formatted, 'writer')},
{'story=John Doe1<br>John Doe2 (story)', getCategory(categories.incorrectly_formatted, 'story')},
{'screenplay=John Doe1<br>John Doe2 (story)', getCategory(categories.incorrectly_formatted, 'screenplay')},
{'teleplay=John Doe1<br>John Doe2 (story)', getCategory(categories.incorrectly_formatted, 'teleplay')},
{'writer=John Doe (book)', getCategory(categories.incorrectly_formatted, 'writer')},
{'writer=John Doe (original novel)', getCategory(categories.incorrectly_formatted, 'writer')},
{'writer=John Doe (manuscript)', getCategory(categories.incorrectly_formatted, 'writer')},
{'writer=John Doe (lyric)', getCategory(categories.temp, 'lyric')},
{'writer=John Doe (dialogue)', getCategory(categories.temp, 'dialogue')},
}, {nowiki=1})
end
function p:test_12_is_based_on_used_correctly()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
-- Valid names
{'based_on=John Doe', ''},
{'based_on=\'\'Great Adventures\'\' by John Doe', ''},
{'based_on=' .. expandTemplate("Based on", {"''Great Adventures''", "John Doe"}), ''},
{'based_on=[[The Book of Virtues]] by John Doe', ''},
{'based_on=' .. expandTemplate("Based on", {"''[[The Book of Virtues]]''", "John Doe"}), ''},
{'based_on=' .. expandTemplate("Based on", {"Selections from ''[[The Book of Virtues]]''", "John Doe"}), ''},
{'based_on=' .. expandTemplate("Based on", {"''Great Adventures'' 1999 Novel", "John Doe"}), getCategory(categories.incorrectly_formatted, 'based_on')},
{'based_on=' .. expandTemplate("Based on", {"''Great Adventures'' 1999 Novel", "John Doe"}), getCategory(categories.incorrectly_formatted, 'based_on')},
{'based_on=' .. expandTemplate("Based on", {"novel", "John Doe"}), getCategory(categories.incorrectly_formatted, 'based_on')},
{'based_on=' .. expandTemplate("Based on", {"book", "John Doe"}), getCategory(categories.incorrectly_formatted, 'based_on')},
{'based_on=novel by John Doe', getCategory(categories.incorrectly_formatted, 'based_on')},
{'based_on=book by John Doe', getCategory(categories.incorrectly_formatted, 'based_on')},
}, {nowiki=1})
end
local function get_date(version)
if version == "start" then
return expandTemplate("Start date", {"1999", "3", "4"})
elseif version == "future" then
return expandTemplate("Start date", {"3000", "3", "4"})
elseif version == "no day" then
return expandTemplate("Start date", {"1999", "3"})
elseif version == "no month" then
return expandTemplate("Start date", {"1999"})
else
return expandTemplate("End date", {"1999", "3", "4"})
end
end
function p:test_13_does_num_episodes_have_extraneous_text()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'num_episodes=', ''},
{'num_episodes=5', ''},
{'num_episodes=Text', ''},
{'num_episodes=5 As of 2022', getCategory(categories.incorrectly_formatted, 'num_episodes')},
{'num_episodes=5' .. get_date("start"), getCategory(categories.incorrectly_formatted, 'num_episodes')},
}, {nowiki=1})
end
function p:test_14_are_dates_formatted_correctly()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', {
{'first_aired=' .. get_date("start") .. '|last_aired=' .. get_date("end"), ''},
{'first_aired=' .. get_date("start") .. '|last_aired=present', ''},
{'released=' .. get_date("start"), ''},
{'released=' .. get_date("start") .. '|first_aired2=' .. get_date("start") .. '|last_aired2=present', ''},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start"), ''},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|first_aired3=' .. get_date("start") .. '|last_aired3=present', ''},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=' .. get_date("start"), ''},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=' .. get_date("start") .. '|first_aired4=' .. get_date("start") .. '|last_aired4=present', ''},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=' .. get_date("start") .. '|released4=' .. get_date("start"), ''},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=' .. get_date("start") .. '|released4=' .. get_date("start") .. '|first_aired5=' .. get_date("start") .. '|last_aired5=present', ''},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=' .. get_date("start") .. '|released4=' .. get_date("start") ..'|released5=' .. get_date("start"), ''},
{'first_aired=Upcoming', ''},
{'released=Upcoming', ''},
{'first_aired=' .. get_date("no day") .. '|last_aired=present', ''},
{'first_aired=' .. get_date("no month") .. '|last_aired=present', ''},
{'', categories.dates_missing},
{'first_aired=' .. get_date("start"), categories.dates_missing},
{'last_aired=' .. get_date("end"), categories.dates_missing},
{'last_aired=present', categories.dates_missing},
{'first_aired=upcoming', categories.dates_incorrectly_formatted},
{'first_aired=bad data', categories.dates_incorrectly_formatted},
{'first_aired=' .. expandTemplate("Start date and age", {"1999", "3", "4"}) .. '|last_aired=present', categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("start") .. '|last_aired=' .. expandTemplate("Start and end dates", {"1939", "9", "1", "1945", "9", "2"}), categories.dates_incorrectly_formatted},
{'first_aired=' .. expandTemplate("Film date", {"1999", "3", "4"}) .. '|last_aired=present', categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("start") .. '|last_aired=' ..expandTemplate("Film date", {"1999", "3", "4"}), categories.dates_incorrectly_formatted},
{'first_aired=4/3/1999', categories.dates_incorrectly_formatted},
{'first_aired=4/3/1999|last_aired=present', categories.dates_incorrectly_formatted},
{'first_aired=March 4, 1999|last_aired=present', categories.dates_incorrectly_formatted},
{'released=4/3/1999', categories.dates_incorrectly_formatted},
{'released=March 4, 1999', categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("start") .. '|last_aired=March 4, 1999', categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("start") .. '|last_aired=Present', categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("start") .. '|last_aired=' .. get_date("start"), categories.dates_incorrectly_formatted},
{'released=' .. get_date("start") .. '|first_aired2=' .. get_date("start"), categories.dates_missing},
{'released=' .. get_date("start") .. '|released2=March 4, 1999', categories.dates_incorrectly_formatted},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|first_aired3=' .. get_date("start"), categories.dates_missing},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=March 4, 1999', categories.dates_incorrectly_formatted},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=' .. get_date("start") .. '|first_aired4=' .. get_date("start"), categories.dates_missing},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=' .. get_date("start") .. '|released4=March 4, 1999', categories.dates_incorrectly_formatted},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=' .. get_date("start") .. '|released4=' .. get_date("start") .. '|first_aired5=' .. get_date("start"), categories.dates_missing},
{'released=' .. get_date("start") .. '|released2=' .. get_date("start") .. '|released3=' .. get_date("start") .. '|released4=' .. get_date("start") .. '|released5=March 4, 1999', categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("start") .. get_date("start") .. '|last_aired=' .. get_date("end"), categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("start") .. '|last_aired=' .. get_date("end").. get_date("end"), categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("future") .. '|last_aired=present', categories.dates_incorrectly_formatted}, -- start date in the future
-- Additional dates as plain text
{'first_aired=March 4, 1999' .. get_date("start") .. 'March 4, 1999' .. '|last_aired=' .. get_date("end"), categories.dates_incorrectly_formatted},
{'first_aired=March 2, ' .. get_date("start") .. '|last_aired=present', categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("start") .. '-present|last_aired=' .. get_date("end"), categories.dates_incorrectly_formatted},
{'first_aired=' .. get_date("start") .. '|last_aired=' .. get_date("end") .. 'March 4, 1999', categories.dates_incorrectly_formatted},
}, {nowiki=1})
end
function p:test_15_does_release_information_have_extraneous_text()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'network=[[Aboriginal Peoples Television Network]]', ''},
{'first_aired=Original series ' .. get_date("start") .. '|last_aired=present', getCategory(categories.incorrectly_formatted, 'first_aired')}, -- find 'original'
{'first_aired=Revival series ' .. get_date("start") .. '|last_aired=present', getCategory(categories.incorrectly_formatted, 'first_aired')}, -- find 'revival'
{'first_aired=' .. get_date("start") .. '|last_aired=Original series ' .. get_date("end"), getCategory(categories.incorrectly_formatted, 'last_aired')}, -- find 'original'
{'first_aired=' .. get_date("start") .. '|last_aired=Revival series ' .. get_date("end"), getCategory(categories.incorrectly_formatted, 'last_aired')}, -- find 'revival'
{'released=Original series ' .. get_date("start"), getCategory(categories.incorrectly_formatted, 'released')}, -- find 'original'
{'released=Revival series ' .. get_date("start"), getCategory(categories.incorrectly_formatted, 'released')}, -- find 'revival'
{'released=original series ' .. get_date("start"), getCategory(categories.incorrectly_formatted, 'released')}, -- find 'original'
{'released=revival series ' .. get_date("start"), getCategory(categories.incorrectly_formatted, 'released')}, -- find 'revival'
{'first_aired2=' .. get_date("start") .. 'Original series|last_aired2=present', getCategory(categories.incorrectly_formatted, 'first_aired2')}, -- find 'original'
{'first_aired2=' .. get_date("start") .. '|last_aired2=Original series ' .. get_date("end"), getCategory(categories.incorrectly_formatted, 'last_aired2')}, -- find 'original'
{'released2=' .. get_date("start") .. 'Original series', getCategory(categories.incorrectly_formatted, 'released2')}, -- find 'original'
{'channel2=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'channel2')}, -- find 'original'
{'network2=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'network2')}, -- find 'original'
{'first_aired3=' .. get_date("start") .. 'Original series|last_aired3=present', getCategory(categories.incorrectly_formatted, 'first_aired3')}, -- find 'original'
{'first_aired3=' .. get_date("start") .. '|last_aired3=Original series ' .. get_date("end"), getCategory(categories.incorrectly_formatted, 'last_aired3')}, -- find 'original'
{'released3=' .. get_date("start") .. 'Original series', getCategory(categories.incorrectly_formatted, 'released3')}, -- find 'original'
{'channel3=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'channel3')}, -- find 'original'
{'network3=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'network3')}, -- find 'original'
{'first_aired4=' .. get_date("start") .. 'Original series|last_aired4=present', getCategory(categories.incorrectly_formatted, 'first_aired4')}, -- find 'original'
{'first_aired4=' .. get_date("start") .. '|last_aired4=Original series ' .. get_date("end"), getCategory(categories.incorrectly_formatted, 'last_aired4')}, -- find 'original'
{'released4=' .. get_date("start") .. 'Original series', getCategory(categories.incorrectly_formatted, 'released4')}, -- find 'original'
{'channel4=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'channel4')}, -- find 'original'
{'network4=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'network4')}, -- find 'original'
{'first_aired5=' .. get_date("start") .. 'Original series|last_aired5=present', getCategory(categories.incorrectly_formatted, 'first_aired5')}, -- find 'original'
{'first_aired5=' .. get_date("start") .. '|last_aired5=Original series ' .. get_date("end"), getCategory(categories.incorrectly_formatted, 'last_aired5')}, -- find 'original'
{'released5=' .. get_date("start") .. 'Original series', getCategory(categories.incorrectly_formatted, 'released5')}, -- find 'original'
{'channel5=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'channel5')}, -- find 'original'
{'network5=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'network5')}, -- find 'original'
{'first_aired6=' .. get_date("start") .. 'Original series|last_aired6=present', getCategory(categories.incorrectly_formatted, 'first_aired6')}, -- find 'original'
{'first_aired6=' .. get_date("start") .. '|last_aired6=Original series ' .. get_date("end"), getCategory(categories.incorrectly_formatted, 'last_aired6')}, -- find 'original'
{'released6=' .. get_date("start") .. 'Original series', getCategory(categories.incorrectly_formatted, 'released6')}, -- find 'original'
{'channel6=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'channel6')}, -- find 'original'
{'network6=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'network6')}, -- find 'original'
{'first_aired7=' .. get_date("start") .. 'Original series|last_aired7=present', getCategory(categories.incorrectly_formatted, 'first_aired7')}, -- find 'original'
{'first_aired7=' .. get_date("start") .. '|last_aired7=Original series ' .. get_date("end"), getCategory(categories.incorrectly_formatted, 'last_aired7')}, -- find 'original'
{'released7=' .. get_date("start") .. 'Original series', getCategory(categories.incorrectly_formatted, 'released7')}, -- find 'original'
{'channel7=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'channel7')}, -- find 'original'
{'network7=Original series [[NBC]]', getCategory(categories.incorrectly_formatted, 'network7')}, -- find 'original'
{'released=\'\'NBC\'\' ' .. get_date("start"), getCategory(categories.incorrectly_formatted, 'released')}, -- find italics
{'first_aired=\'\'NBC\'\' ' .. get_date("start") .. '|last_aired=present', getCategory(categories.incorrectly_formatted, 'first_aired')}, -- find italics
{'first_aired=' .. get_date("start") .. '|last_aired=\'\'NBC\'\' ' .. get_date("end"), getCategory(categories.incorrectly_formatted, 'last_aired')}, -- find italics
{'channel=\'\'New series\'\' [[NBC]]', getCategory(categories.incorrectly_formatted, 'channel')}, -- find italics
{'network4=revival [[NBC]]', getCategory(categories.incorrectly_formatted, 'network4')}, -- find 'revival'
{'channel4=[[NBC]] revival', getCategory(categories.incorrectly_formatted, 'channel4')}, -- find 'revival'
}, {nowiki=1})
end
function p:test_16_are_values_unlinked()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'', ''},
{'network=[[NBC]]', ''},
{'network2=[[NBC]]', ''},
{'network3=[[NBC]]', ''},
{'network4=[[NBC]]', ''},
{'network5=[[NBC]]', ''},
{'network6=[[NBC]]', ''},
{'network7=[[NBC]]', ''},
{'channel=[[NBC]]', ''},
{'channel2=[[NBC]]', ''},
{'channel3=[[NBC]]', ''},
{'channel4=[[NBC]]', ''},
{'channel5=[[NBC]]', ''},
{'channel6=[[NBC]]', ''},
{'channel7=[[NBC]]', ''},
{'network=NBC', getCategory(categories.unlinked_values, 'network')},
{'network2=NBC', getCategory(categories.unlinked_values, 'network')},
{'network3=NBC', getCategory(categories.unlinked_values, 'network')},
{'network4=NBC', getCategory(categories.unlinked_values, 'network')},
{'network5=NBC', getCategory(categories.unlinked_values, 'network')},
{'network6=NBC', getCategory(categories.unlinked_values, 'network')},
{'network7=NBC', getCategory(categories.unlinked_values, 'network')},
{'channel=NBC', getCategory(categories.unlinked_values, 'channel')},
{'channel2=NBC', getCategory(categories.unlinked_values, 'channel')},
{'channel3=NBC', getCategory(categories.unlinked_values, 'channel')},
{'channel4=NBC', getCategory(categories.unlinked_values, 'channel')},
{'channel5=NBC', getCategory(categories.unlinked_values, 'channel')},
{'channel6=NBC', getCategory(categories.unlinked_values, 'channel')},
{'channel7=NBC', getCategory(categories.unlinked_values, 'channel')},
{'network=[[NBC]]<br/>[[ABC]]', ''},
{'network=NBC<br/>ABC', getCategory(categories.unlinked_values, 'network')}, --TODO: currently does not work
--TODO: readd when code is added to handle this: {'network=[[NBC]]<br/>ABC', getCategory(categories.unlinked_values, 'network')}, --TODO: currently does not work
--TODO: readd when code is added to handle this: {'network=ABC<br/>[[NBC]]', getCategory(categories.unlinked_values, 'network')}, --TODO: currently does not work
{'network=' .. expandTemplate("Plainlist", {"* [[ABC]]\n* [[NBC]]\n"}), ''},
{'network=' .. expandTemplate("Plainlist", {"* ABC\n* NBC\n"}), getCategory(categories.unlinked_values, 'network')}, --TODO: currently does not work
--TODO: readd when code is added to handle this: {'network=' .. expandTemplate("Plainlist", {"* ABC\n* [[NBC]]\n"}), getCategory(categories.unlinked_values, 'network')}, --TODO: currently does not work
}, {nowiki=1})
end
function p:test_17_are_network_parameters_duplicated()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'', ''},
{'image=test|image_alt=test|alt=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'image=test|image_size=250|image_upright=2', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'based_on=test|inspired_by=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'screenplay=test|teleplay=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'presenter=test|host=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'narrator=test|narrated=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'narrator=test|announcer=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'narrated=test|announcer=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'theme_music_composer=test|music=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'open_theme=test|opentheme=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'end_theme=test|endtheme=test', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'network=[[NBC]]', ''},
{'network2=[[NBC]]', ''},
{'network3=[[NBC]]', ''},
{'network4=[[NBC]]', ''},
{'network5=[[NBC]]', ''},
{'network6=[[NBC]]', ''},
{'network7=[[NBC]]', ''},
{'channel=[[NBC]]', ''},
{'channel2=[[NBC]]', ''},
{'channel3=[[NBC]]', ''},
{'channel4=[[NBC]]', ''},
{'channel5=[[NBC]]', ''},
{'channel6=[[NBC]]', ''},
{'channel7=[[NBC]]', ''},
{'network=[[NBC]]|channel=', ''},
{'network2=[[NBC]]|channel=', ''},
{'network3=[[NBC]]|channel=', ''},
{'network4=[[NBC]]|channel=', ''},
{'network5=[[NBC]]|channel=', ''},
{'network6=[[NBC]]|channel=', ''},
{'network7=[[NBC]]|channel=', ''},
{'network=[[NBC]]|channel=[[NBC]]', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'network2=[[NBC]]|channel2=[[NBC]]', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'network3=[[NBC]]|channel3=[[NBC]]', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'network4=[[NBC]]|channel4=[[NBC]]', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'network5=[[NBC]]|channel5=[[NBC]]', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'network6=[[NBC]]|channel6=[[NBC]]', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'network7=[[NBC]]|channel7=[[NBC]]', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'network=[[NBC]]|channel=[[CBS]]', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'first_aired=' .. get_date("start") .. '|released=' .. get_date("start") .. 'last_aired=present', getCategory(categories.incorrectly_formatted, "-duplicate")},
{'released=' .. get_date("start") .. '|last_aired=present', getCategory(categories.incorrectly_formatted, "-duplicate")},
}, {nowiki=1})
end
function p:test_18_has_external_links()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'', ''},
{'company=[http://www.roughcut-tv.com/]', getCategory(categories.incorrectly_formatted, 'company')},
{'director=[http://www.roughcut-tv.com/ Roughcut]', getCategory(categories.incorrectly_formatted, 'director')},
{'writer=[http://www.roughcut-tv.com/ Roughcut TV]', getCategory(categories.incorrectly_formatted, 'writer')},
{'writer=[https://www.roughcut-tv.com/ Roughcut TV]', getCategory(categories.incorrectly_formatted, 'writer')},
{'writer=[http://www.roughcut-tv.com]', getCategory(categories.incorrectly_formatted, 'writer')},
{'director=Good director' .. mw.getCurrentFrame():callParserFunction('#tag', {'ref', 'http://www.roughcut-tv.com/'} ), ''},
{'writer=Good writer' .. expandTemplate("efn", {"http://www.roughcut-tv.com/"}), ''},
}, {nowiki=1})
end
function p:test_20_is_italic_title_valid_value()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values|all_tests=no', {
{'', ''},
{'italic_title=no', ''},
{'italic_title=n', getCategory(categories.incorrectly_formatted, 'italic_title')},
{'italic_title=y', getCategory(categories.incorrectly_formatted, 'italic_title')},
}, {nowiki=1})
end
function p:test_21_all_errors()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', {
{'page_title_test=Test|name=Test|page_test=Module:Infobox television/italic test6|image_size=1|series=Lost|director=' .. expandTemplate("USA", {}) .. 'test|first_aired=4/3/1999|italic_title=y',
categories.unnecessary_title_parameter ..
categories.manual_display_title ..
categories.image_values_without_an_image ..
categories.flag_icon ..
categories.dates_incorrectly_formatted ..
getCategory(categories.incorrectly_formatted, 'italic_title')
},
}, {nowiki=1})
end
local function handle_title(text)
return "''".. text .. "''"
end
function p:test_20_above_title()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'above_title', {
{'name=title', handle_title('title')},
{'name=title (dab)', handle_title('title (dab)')},
{'name=#title', handle_title('#title')},
{'page_test=Lost (2004 TV series)', handle_title('Lost')},
{'page_test=I (Almost) Got Away With It|name=I (Almost) Got Away With It', handle_title('I (Almost) Got Away With It')},
{'page_test=I (Almost) Got Away With It', handle_title('I (Almost) Got Away With It')},
{'page_test=How to Live with Your Parents (For the Rest of Your Life)|name=How to Live with Your Parents (For the Rest of Your Life)', handle_title('How to Live with Your Parents (For the Rest of Your Life)')},
{'page_test=How to Live with Your Parents (For the Rest of Your Life)', handle_title('How to Live with Your Parents')},
{'page_test=Hashtag Like|italic_title=no', handle_title('#Like')}, --Correct title
{'page_test=Hashtag Like|name=#Like', handle_title('#Like')}, --Correct title
{'page_test=Das aktuelle sportstudio|italic_title=no', handle_title('das aktuelle sportstudio')}, --Lowercase title
{'page_test=Das aktuelle sportstudio|name=das aktuelle sportstudio', handle_title('das aktuelle sportstudio')}, --Lowercase title
{'page_test=News2day|italic_title=no', handle_title('news2day')}, --Displaytitle
{'page_test=News2day|name=news2day', handle_title('news2day')}, --Displaytitle
{'page_test=H2O (miniseries)|italic_title=no', handle_title('H<sub>2</sub>O')}, --Displaytitle with special style
{'page_test=H2O (miniseries)|name=H<sub>2</sub>O', handle_title('H<sub>2</sub>O')}, --Displaytitle with special style
{'page_test=Wednesday 9:30 (8:30 Central)|italic_title=no', handle_title('Wednesday 9:30 (8:30 Central)')}, --Itatlic title|all=yes
}, {nowiki=1})
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.