Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Infobox television/testcases
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- Unit tests for [[Module:Infobox television]]. Click talk page to run tests. local p = require('Module:UnitTests') local function expandTemplate(template, value) local frame = mw.getCurrentFrame() return frame:expandTemplate{title = template, args = value} end function p:test_01_is_infobox_title_equal_to_article_title() self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', { {'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', '[[Category:Pages using infobox television with unnecessary name parameter]]'}, {'page_title_test=Test (not dab)|name=Test (not dab)', '[[Category:Pages using infobox television with unnecessary name parameter]]'}, {'page_title_test=Test (dab)|name=Test', '[[Category:Pages using infobox television with unnecessary name parameter]]'}, {'page_title_test=Test|name=test', '[[Category:Pages using infobox television with non-matching title]]'}, {'page_title_test=Long article title|name=' .. expandTemplate("Nowrap", {"Long article Title"}), '[[Category:Pages using infobox television with non-matching title]]'}, {'page_title_test=Long article title|name=Long article <br/> Title', '[[Category:Pages using infobox television with non-matching title]]'}, }, {nowiki=1}) end function p:test_02_has_display_title() self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', { {'', ''}, {'page_test=Template:Italic title/doc', '[[Category:Pages using infobox television with unnecessary manual displaytitle]]'}, --- {'page_test=News2day', '[[Category:Pages using infobox television with manual displaytitle]]'}, --Displaytitle -- need a new example }, {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', { {'image=test|image_size=1', ''}, {'image_size=1', '[[Category:Pages using infobox television with image-related values without an image]]'}, {'image_upright=1', '[[Category:Pages using infobox television with image-related values without an image]]'}, {'image_alt=test', '[[Category:Pages using infobox television with image-related values without an image]]'}, {'alt=test', '[[Category:Pages using infobox television with image-related values without an image]]'}, {'caption=test', '[[Category:Pages using infobox television with image-related 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', { {'image=image.jpg', ''}, {'image=File:image.jpg', '[[Category:Pages using infobox television with incorrectly formatted values|image]]'}, {'image=[[File:image.jpg]]', '[[Category:Pages using infobox television with incorrectly formatted values|image]]'}, {'image=Image:image.jpg', '[[Category:Pages using infobox television with incorrectly formatted values|image]]'}, {'image=[[Image:image.jpg]]', '[[Category:Pages using infobox television with incorrectly formatted values|image]]'}, }, {nowiki=1}) end function p:test_05_is_image_size_using_px() self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', { {'image=test|image_size=100', ''}, {'image=test|image_size=100px', '[[Category:Pages using infobox television with incorrectly formatted values|image_size]]'}, }, {nowiki=1}) end function p:test_06_are_values_linked_or_formatted() self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', { {'language=English', ''}, {'language=[[English]]', '[[Category:Pages using infobox television with incorrectly formatted values|language]]'}, }, {nowiki=1}) end function p:test_08_has_flag_icon() self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', { {'director=' .. expandTemplate("USA", {}) .. 'test', '[[Category:Pages using infobox television with flag icon]]'}, }, {nowiki=1}) end function p:test_09_are_dates_formatted_correctly() self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', { {'first_aired=' .. expandTemplate("Start date", {"1999", "3", "4"}), ''}, {'released=' .. expandTemplate("Start date", {"1999", "3", "4"}), ''}, {'last_aired=' .. expandTemplate("End date", {"1999", "3", "4"}), ''}, {'last_aired=present', ''}, {'first_aired=4/3/1999', '[[Category:Pages using infobox television with nonstandard dates]]'}, {'first_aired=March 4, 1999', '[[Category:Pages using infobox television with nonstandard dates]]'}, {'released=4/3/1999', '[[Category:Pages using infobox television with nonstandard dates]]'}, {'released=March 4, 1999', '[[Category:Pages using infobox television with nonstandard dates]]'}, {'last_aired=March 4, 1999', '[[Category:Pages using infobox television with nonstandard dates]]'}, {'last_aired=Present', '[[Category:Pages using infobox television with nonstandard dates]]'}, {'last_aired=' .. expandTemplate("Start date", {"1999", "3", "4"}), '[[Category:Pages using infobox television with nonstandard dates]]'}, }, {nowiki=1}) end function p:test_10_is_italic_title_valid_value() self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', { {'', ''}, {'italic_title=no', ''}, {'italic_title=n', '[[Category:Pages using infobox television with incorrectly formatted values|Italic title]]'}, {'italic_title=y', '[[Category:Pages using infobox television with incorrectly formatted values|Italic title]]'}, }, {nowiki=1}) end function p:test_11_all_errors() self:preprocess_equals_sandbox_many('{{#invoke:Infobox television', 'validate_values', { {'page_title_test=Test|name=Test|page_test=Template:Italic title/doc|image_size=1|series=Lost|director=' .. expandTemplate("USA", {}) .. 'test|first_aired=4/3/1999|italic_title=y', '[[Category:Pages using infobox television with unnecessary name parameter]][[Category:Pages using infobox television with unnecessary manual displaytitle]][[Category:Pages using infobox television with image-related values without an image]][[Category:Pages using infobox television with flag icon]][[Category:Pages using infobox television with nonstandard dates]][[Category:Pages using infobox television with incorrectly formatted values|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 (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
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Infobox television/testcases/doc
(
edit
)