-- Unit tests for . Run all tests on the talk page.-- Due to the changable nature of short descriptions; some of these tests may need to be updated before running them.
local p = require('Module:UnitTests')
--empty params
function p:test__no_name_param self:preprocess_equals('', '
requires a page name (including namespace).',)endfunction p:test__no_name_value self:preprocess_equals('', '
requires a page name (including namespace).',)endfunction p:test__no_display_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_quote_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_abbr_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_abbr_value__abbr_title self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_abbr__no_abbr_title_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_aka_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_wedge_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_dash_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_desc_first_letter_case_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_link_lang_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
-- tests for empty |link_lang_italic= |link_lang_nocat= |link_lang_size= |link_lang_cat= |link_lang_rtl= ?
function p:test__no_aka_lang_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
-- tests for empty |aka_lang_italic= |aka_lang_nocat= |aka_lang_size= |aka_lang_cat= |aka_lang_rtl= ?
function p:test__no_wedge_lang_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
-- tests for empty |wedge_lang_italic= |wedge_lang_nocat= |wedge_lang_size= |wedge_lang_cat= |wedge_lang_rtl= ?
function p:test__no_only_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_prefer_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__no_fallback_value self:preprocess_equals('', "User:Fred Gandt/sandbox/no explicit short description")end
--unknown param
function p:test__no_unknown_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__unknown_value self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
--none but name
function p:test__short_description_exists self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__short_description_does_not_exist self:preprocess_equals('', "User:Fred Gandt/sandbox/no explicit short description")end
--template links
function p:test__template_link__only_explicit self:preprocess_equals('', "")end
function p:test__template_link_code__only_explicit self:preprocess_equals('', "{{[[:Template:annotated link|annotated link]]}}
",)end
function p:test__template_link_no__only_explicit self:preprocess_equals('', "Template:Annotated link")end
function p:test__template_link_no__display__only_explicit self:preprocess_equals('', "Annotated link")end
--name and display
function p:test__display__short_description_exists self:preprocess_equals('', "Test page – Explicit short description")end
function p:test__display__short_description_does_not_exist self:preprocess_equals('', "Test page")end
--name and quote
function p:test__quote__short_description_exists self:preprocess_equals('', '"User:Fred Gandt/sandbox/explicit short description" – Explicit short description')end
function p:test__quote__short_description_does_not_exist self:preprocess_equals('', '"User:Fred Gandt/sandbox/no explicit short description"')end
--name and abbr
function p:test__abbr__short_description_exists self:preprocess_equals('', 'User:Fred Gandt/sandbox/explicit short description (ESD) – Explicit short description',)end
function p:test__abbr__short_description_does_not_exist self:preprocess_equals('', 'User:Fred Gandt/sandbox/no explicit short description (NESD)',)end
--name, abbr and abbr_title
function p:test__abbr__abbr_title__short_description_exists self:preprocess_equals('', 'User:Fred Gandt/sandbox/explicit short description (ESD) – Explicit short description',)end
function p:test__abbr__abbr_title__short_description_does_not_exist self:preprocess_equals('', 'User:Fred Gandt/sandbox/no explicit short description (NESD)',)end
--name and aka
function p:test__aka__short_description_exists self:preprocess_equals("", "User:Fred Gandt/sandbox/explicit short description, also known as Fred's test page – Explicit short description")end
function p:test__aka__short_description_does_not_exist self:preprocess_equals("", "User:Fred Gandt/sandbox/no explicit short description, also known as Fred's test page")end
--name and wedge
function p:test__wedge__short_description_exists self:preprocess_equals("", "User:Fred Gandt/sandbox/explicit short description, Tight Fit – Explicit short description")end
function p:test__wedge__short_description_does_not_exist self:preprocess_equals("", "User:Fred Gandt/sandbox/no explicit short description, Tight Fit")end
--name, abbr and aka
function p:test__abbr__aka__short_description_exists self:preprocess_equals("", "User:Fred Gandt/sandbox/explicit short description (ESD), also known as Fred's test page – Explicit short description",)end
function p:test__abbr__aka__short_description_does_not_exist self:preprocess_equals("", "User:Fred Gandt/sandbox/no explicit short description (NESD), also known as Fred's test page",)end
--name, abbr and wedge
function p:test__abbr__wedge__short_description_exists self:preprocess_equals("", "User:Fred Gandt/sandbox/explicit short description (ESD), Tight Fit – Explicit short description",)end
function p:test__abbr__wedge__short_description_does_not_exist self:preprocess_equals("", "User:Fred Gandt/sandbox/no explicit short description (NESD), Tight Fit",)end
--name, abbr, aka and wedge
function p:test__abbr__aka__wedge__short_description_exists self:preprocess_equals("", "User:Fred Gandt/sandbox/explicit short description (ESD), also known as Fred's test page, Tight Fit – Explicit short description",)end
function p:test__abbr__aka__wedge__short_description_does_not_exist self:preprocess_equals("", "User:Fred Gandt/sandbox/no explicit short description (NESD), also known as Fred's test page, Tight Fit",)end
--name, aka and wedge
function p:test__aka__wedge__short_description_exists self:preprocess_equals("", "User:Fred Gandt/sandbox/explicit short description, also known as Fred's test page, Tight Fit – Explicit short description")end
function p:test__aka__wedge__short_description_does_not_exist self:preprocess_equals("", "User:Fred Gandt/sandbox/no explicit short description, also known as Fred's test page, Tight Fit")end
--name and link_lang en
function p:test__link_lang_en self:preprocess_equals('', "User:Fred Gandt/sandbox/no explicit short description")end
--name, display and link_lang fr
function p:test__display__link_lang_fr self:preprocess_equals('', '
La page de test de Fred',)end--name, display, quote and link_lang fr
function p:test__display__quote__link_lang_fr self:preprocess_equals('', '"
La page de test de Fred"',)end--name, aka and aka_lang ja
function p:test__aka__aka_lang_ja self:preprocess_equals("", 'User:Fred Gandt/sandbox/no explicit short description, also known as
フレッドのテストページ',)end--name, wedge and wedge_lang ga
function p:test__wedge__wedge_lang_ga self:preprocess_equals("", 'User:Fred Gandt/sandbox/no explicit short description,
Leathanach tástála Fred',)end--name and mixed language
function p:test__mixed_language self:preprocess_equals('', '
La page de test de Fred, also known as フレッドのテストページ, Leathanach tástála Fred',)endfunction p:test__dash_value_comma self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description, Explicit short description")end
function p:test__desc_first_letter_case_upper self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
--categorisation of short descriptions with no spaces being displayed
function p:test__categorise_no_space_descriptions self:preprocess_equals('', 'User:Fred Gandt/sandbox/explicit short description with no spaces – Spacelessness
',)endfunction p:test__categorise_no_space_descriptions__space_cat self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description with no spaces – Spacelessness")end
--
--only explicit
function p:test__only_explicit__explicit_exists self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
function p:test__only_explicit__explicit_does_not_exist self:preprocess_equals('', "User:Fred Gandt/sandbox/no explicit short description")end
--only wikidata
function p:test__only_wikidata__wikidata_exists self:preprocess_equals('', "Wikipedia – free multilingual online encyclopedia")end
function p:test__only_wikidata__wikidata_does_not_exist self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description")end
--prefer explicit
function p:test__only_explicit__explicit_exists__wikidata_exists self:preprocess_equals('', "Wikipedia – Free online crowd-sourced encyclopedia")end
function p:test__only_explicit__explicit_does_not_exist__wikidata_exists self:preprocess_equals('', 'Example – Wikimedia disambiguation page
',)end--prefer wikidata
function p:test__only_wikidata__wikidata_exists__explicit_exists self:preprocess_equals('', "Wikipedia – free multilingual online encyclopedia")end
function p:test__only_wikidata__wikidata_does_not_exist__explicit_exists self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – Explicit short description")end
-- fallback
function p:test__only_explicit__fallback__explicit_does_not_exist self:preprocess_equals('', "User:Fred Gandt/sandbox/no explicit short description – this is a fallback")end
function p:test__only_wikidata__fallback__wikidata_does_not_exist self:preprocess_equals('', "User:Fred Gandt/sandbox/explicit short description – this is a fallback")end
-- prefix_parentheses
function p:test__prefix_parentheses self:preprocess_equals('', "Jimmy Wales (born 1966), co-founder of Wikipedia") self:preprocess_equals('', "Jimmy Wales, co-founder of Wikipedia (born 1966)")end
--test the test; sanity check; should fail
--function p:test_the_test-- self:preprocess_equals('', "test the test")--end
--foreign language wikidata
-- Testing |desc_lang_italic= |desc_lang_nocat= |desc_lang_size= |desc_lang_cat= |desc_lang_rtl= |desc_lang_no= will require a wikidata description in a language other than English to be returned
return p