Jump to content

Module:GetShortDescription/sandbox/testcases: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
this module won't handle fallback anymore; removed
stringify results for direct invocations
Line 7: Line 7:


function p:test__no_name_param()
function p:test__no_name_param()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main}}', '<span style="color:#d33">[[Module:GetShortDescription]] requires a page name (including namespace).</span>[[Category:Pages displaying alarming messages about Module:GetShortDescription]]', {nowiki = 1})
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes}}', '<span style="color:#d33">[[Module:GetShortDescription]] requires a page name (including namespace).</span>[[Category:Pages displaying alarming messages about Module:GetShortDescription]]', {nowiki = 1})
end
end


function p:test__no_name_value()
function p:test__no_name_value()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=}}', '<span style="color:#d33">[[Module:GetShortDescription]] requires a page name (including namespace).</span>[[Category:Pages displaying alarming messages about Module:GetShortDescription]]', {nowiki = 1})
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=}}', '<span style="color:#d33">[[Module:GetShortDescription]] requires a page name (including namespace).</span>[[Category:Pages displaying alarming messages about Module:GetShortDescription]]', {nowiki = 1})
end
end


function p:test__no_only_value()
function p:test__no_only_value()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|only=}}', "Explicit short description")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=}}', "Explicit short description")
end
end


function p:test__no_prefer_value()
function p:test__no_prefer_value()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|prefer=}}', "Explicit short description")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|prefer=}}', "Explicit short description")
end
end


function p:test__no_objectify_alarm_value()
function p:test__no_objectify_alarm_value()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|objectify_alarm=}}', '<span style="color:#d33">[[Module:GetShortDescription]] requires a page name (including namespace).</span>[[Category:Pages displaying alarming messages about Module:GetShortDescription]]', {nowiki = 1})
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|objectify_alarm=}}', '<span style="color:#d33">[[Module:GetShortDescription]] requires a page name (including namespace).</span>[[Category:Pages displaying alarming messages about Module:GetShortDescription]]', {nowiki = 1})
end
end


Line 29: Line 29:


function p:test__nonexistent_page_name()
function p:test__nonexistent_page_name()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/nonexistent page}}', '')
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/nonexistent page}}', '')
end
end


Line 35: Line 35:


function p:test__unknown_param_with_no_value_offered()
function p:test__unknown_param_with_no_value_offered()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|unknown=}}', "Explicit short description")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|unknown=}}', "Explicit short description")
end
end


function p:test__unknown_param_with_value_offered()
function p:test__unknown_param_with_value_offered()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|unknown=unknown}}', "Explicit short description")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|unknown=unknown}}', "Explicit short description")
end
end


Line 45: Line 45:


function p:test__unknown_param_found()
function p:test__unknown_param_found()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description with unknown params}}', "Explicit short description with unknown params")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description with unknown params}}', "Explicit short description with unknown params")
end
end


function p:test__complex_unknown_params_found()
function p:test__complex_unknown_params_found()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description with complex unknown params}}', "Explicit short description with complex unknown params")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description with complex unknown params}}', "Explicit short description with complex unknown params")
end
end


Line 57: Line 57:


function p:test__two_short_descriptions_numbered_after()
function p:test__two_short_descriptions_numbered_after()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/two explicit short descriptions numbered after}}', "Explicit short description numbered second (used)")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short descriptions numbered after}}', "Explicit short description numbered second (used)")
end
end


function p:test__two_short_descriptions_numbered_before()
function p:test__two_short_descriptions_numbered_before()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/two explicit short descriptions numbered before}}', "Explicit short description unnumbered second (used)")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short descriptions numbered before}}', "Explicit short description unnumbered second (used)")
end
end


Line 67: Line 67:


function p:test__two_short_description_templates()
function p:test__two_short_description_templates()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/two explicit short description templates}}', "Explicit short description second (used)")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short description templates}}', "Explicit short description second (used)")
end
end


function p:test__two_short_description_templates__first_noreplace()
function p:test__two_short_description_templates__first_noreplace()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/two explicit short description templates first noreplace}}', "Explicit short description second (used)")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short description templates first noreplace}}', "Explicit short description second (used)")
end
end


function p:test__two_short_description_templates__second_noreplace()
function p:test__two_short_description_templates__second_noreplace()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/two explicit short description templates second noreplace}}', "Explicit short description first (used)")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short description templates second noreplace}}', "Explicit short description first (used)")
end
end


function p:test__three_short_description_templates__second_noreplace()
function p:test__three_short_description_templates__second_noreplace()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/three explicit short description templates second noreplace}}', "Explicit short description third (used)")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/three explicit short description templates second noreplace}}', "Explicit short description third (used)")
end
end


function p:test__three_short_description_templates__second_none__third_noreplace()
function p:test__three_short_description_templates__second_none__third_noreplace()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/three explicit short description templates second none third noreplace}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/three explicit short description templates second none third noreplace}}', "")
end
end


Line 89: Line 89:


function p:test__explicit_exists__wikidata_does_not_exist()
function p:test__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description}}', "Explicit short description")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description}}', "Explicit short description")
end
end


function p:test__explicit_does_not_exist__wikidata_does_not_exist()
function p:test__explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/no explicit short description}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description}}', "")
end
end


function p:test__explicit_exists__wikidata_exists()
function p:test__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Wikipedia}}', "Free multilingual, online, crowdsourced encyclopedia")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia}}', "Free multilingual, online, crowdsourced encyclopedia")
end
end


function p:test__explicit_does_not_exist__wikidata_exists()
function p:test__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Example}}', "table")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example}}', "")
end
end


Line 107: Line 107:


function p:test__only_explicit__explicit_exists__wikidata_does_not_exist()
function p:test__only_explicit__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|only=explicit}}', "Explicit short description")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=explicit}}', "Explicit short description")
end
end


function p:test__only_wikidata__explicit_exists__wikidata_does_not_exist()
function p:test__only_wikidata__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|only=wikidata}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=wikidata}}', "")
end
end


function p:test__only_explicit__explicit_does_not_exist__wikidata_does_not_exist()
function p:test__only_explicit__explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit}}', "")
end
end


function p:test__only_wikidata__explicit_does_not_exist__wikidata_does_not_exist()
function p:test__only_wikidata__explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/no explicit short description|only=wikidata}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|only=wikidata}}', "")
end
end


function p:test__only_explicit__explicit_exists__wikidata_exists()
function p:test__only_explicit__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Wikipedia|only=explicit}}', "Free multilingual, online, crowdsourced encyclopedia")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|only=explicit}}', "Free multilingual, online, crowdsourced encyclopedia")
end
end


function p:test__only_wikidata__explicit_exists__wikidata_exists()
function p:test__only_wikidata__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Wikipedia|only=wikidata}}', "free multilingual online encyclopedia")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|only=wikidata}}', "free multilingual online encyclopedia")
end
end


function p:test__only_explicit__explicit_does_not_exist__wikidata_exists()
function p:test__only_explicit__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Example|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|only=explicit}}', "")
end
end


function p:test__only_wikidata__explicit_does_not_exist__wikidata_exists()
function p:test__only_wikidata__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Example|only=wikidata}}', "Wikimedia disambiguation page")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|only=wikidata}}', "Wikimedia disambiguation page")
end
end


Line 141: Line 141:


function p:test__prefer_explicit__explicit_exists__wikidata_does_not_exist()
function p:test__prefer_explicit__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|prefer=explicit}}', "Explicit short description")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|prefer=explicit}}', "Explicit short description")
end
end


function p:test__prefer_wikidata__explicit_exists__wikidata_does_not_exist()
function p:test__prefer_wikidata__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|prefer=wikidata}}', "Explicit short description")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|prefer=wikidata}}', "Explicit short description")
end
end


function p:test__prefer_explicit__explicit_does_not_exist__wikidata_does_not_exist()
function p:test__prefer_explicit__explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/no explicit short description|prefer=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|prefer=explicit}}', "")
end
end


function p:test__prefer_wikidata__explicit_does_not_exist__wikidata_does_not_exist()
function p:test__prefer_wikidata__explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/no explicit short description|prefer=wikidata}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|prefer=wikidata}}', "")
end
end


function p:test__prefer_explicit__explicit_exists__wikidata_exists()
function p:test__prefer_explicit__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Wikipedia|prefer=explicit}}', "Free multilingual, online, crowdsourced encyclopedia")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|prefer=explicit}}', "Free multilingual, online, crowdsourced encyclopedia")
end
end


function p:test__prefer_wikidata__explicit_exists__wikidata_exists()
function p:test__prefer_wikidata__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Wikipedia|prefer=wikidata}}', "free multilingual online encyclopedia")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|prefer=wikidata}}', "free multilingual online encyclopedia")
end
end


function p:test__prefer_explicit__explicit_does_not_exist__wikidata_exists()
function p:test__prefer_explicit__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Example|prefer=explicit}}', "table")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|prefer=explicit}}', "")
end
end


function p:test__prefer_wikidata__explicit_does_not_exist__wikidata_exists()
function p:test__prefer_wikidata__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Example|prefer=wikidata}}', "Wikimedia disambiguation page")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|prefer=wikidata}}', "Wikimedia disambiguation page")
end
end


Line 176: Line 176:


function p:test__conflicting__only_explicit__prefer_wikidata__explicit_exists__wikidata_does_not_exist()
function p:test__conflicting__only_explicit__prefer_wikidata__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|only=explicit|prefer=wikidata}}', "Explicit short description")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=explicit|prefer=wikidata}}', "Explicit short description")
end
end


function p:test__conflicting__only_explicit__prefer_wikidata__explicit_does_not_exist__wikidata_does_not_exist()
function p:test__conflicting__only_explicit__prefer_wikidata__explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit|prefer=wikidata}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit|prefer=wikidata}}', "")
end
end


function p:test__conflicting__only_explicit__prefer_wikidata__explicit_exists__wikidata_exists()
function p:test__conflicting__only_explicit__prefer_wikidata__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Wikipedia|only=explicit|prefer=wikidata}}', "Free multilingual, online, crowdsourced encyclopedia")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|only=explicit|prefer=wikidata}}', "Free multilingual, online, crowdsourced encyclopedia")
end
end


function p:test__conflicting__only_explicit__prefer_wikidata__explicit_does_not_exist__wikidata_exists()
function p:test__conflicting__only_explicit__prefer_wikidata__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Example|only=explicit|prefer=wikidata}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|only=explicit|prefer=wikidata}}', "")
end
end


Line 194: Line 194:


function p:test__conflicting__only_wikidata__prefer_explicit__explicit_exists__wikidata_does_not_exist()
function p:test__conflicting__only_wikidata__prefer_explicit__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description|only=wikidata|prefer=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=wikidata|prefer=explicit}}', "")
end
end


function p:test__conflicting__only_wikidata__prefer_explicit__explicit_does_not_exist__wikidata_does_not_exist()
function p:test__conflicting__only_wikidata__prefer_explicit__explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/no explicit short description|only=wikidata|prefer=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|only=wikidata|prefer=explicit}}', "")
end
end


function p:test__conflicting__only_wikidata__prefer_explicit__explicit_exists__wikidata_exists()
function p:test__conflicting__only_wikidata__prefer_explicit__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Wikipedia|only=wikidata|prefer=explicit}}', "free multilingual online encyclopedia")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|only=wikidata|prefer=explicit}}', "free multilingual online encyclopedia")
end
end


function p:test__conflicting__only_wikidata__prefer_explicit__explicit_does_not_exist__wikidata_exists()
function p:test__conflicting__only_wikidata__prefer_explicit__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Example|only=wikidata|prefer=explicit}}', "Wikimedia disambiguation page")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|only=wikidata|prefer=explicit}}', "Wikimedia disambiguation page")
end
end


Line 212: Line 212:


function p:test__only_explicit__undefined()
function p:test__only_explicit__undefined()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description undefined|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description undefined|only=explicit}}', "")
end
end


function p:test__only_explicit__empty()
function p:test__only_explicit__empty()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description empty|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description empty|only=explicit}}', "")
end
end


function p:test__only_explicit__none()
function p:test__only_explicit__none()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description none|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description none|only=explicit}}', "")
end
end


function p:test__only_explicit__numbered()
function p:test__only_explicit__numbered()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description numbered|only=explicit}}', "Explicit short description numbered")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description numbered|only=explicit}}', "Explicit short description numbered")
end
end


function p:test__only_explicit__complex()
function p:test__only_explicit__complex()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description complex|only=explicit}}', "Explicit short description complex")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex|only=explicit}}', "Explicit short description complex")
end
end


function p:test__only_explicit__complex__numbered()
function p:test__only_explicit__complex__numbered()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description complex numbered|only=explicit}}', "Explicit short description complex numbered")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex numbered|only=explicit}}', "Explicit short description complex numbered")
end
end


function p:test__only_explicit__numbered__empty()
function p:test__only_explicit__numbered__empty()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description numbered empty|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description numbered empty|only=explicit}}', "")
end
end


function p:test__only_explicit__numbered__none()
function p:test__only_explicit__numbered__none()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description numbered none|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description numbered none|only=explicit}}', "")
end
end


function p:test__only_explicit__complex__empty()
function p:test__only_explicit__complex__empty()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description complex empty|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex empty|only=explicit}}', "")
end
end


function p:test__only_explicit__complex__none()
function p:test__only_explicit__complex__none()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description complex none|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex none|only=explicit}}', "")
end
end


function p:test__only_explicit__complex__numbered__empty()
function p:test__only_explicit__complex__numbered__empty()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description complex numbered empty|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex numbered empty|only=explicit}}', "")
end
end


function p:test__only_explicit__complex__numbered__none()
function p:test__only_explicit__complex__numbered__none()
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=User:Fred Gandt/sandbox/explicit short description complex numbered none|only=explicit}}', "")
self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex numbered none|only=explicit}}', "")
end
end


Line 262: Line 262:


--function p:test__the_test()
--function p:test__the_test()
-- self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|name=Example}}', "test the test")
-- self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example}}', "test the test")
--end
--end



Revision as of 02:04, 11 February 2023

-- Unit tests for [[Module:GetShortDescription]]. 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('{{#invoke:GetShortDescription/sandbox|main|stringify=yes}}', '<span style="color:#d33">[[Module:GetShortDescription]] requires a page name (including namespace).</span>[[Category:Pages displaying alarming messages about Module:GetShortDescription]]', {nowiki = 1})
end

function p:test__no_name_value()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=}}', '<span style="color:#d33">[[Module:GetShortDescription]] requires a page name (including namespace).</span>[[Category:Pages displaying alarming messages about Module:GetShortDescription]]', {nowiki = 1})
end

function p:test__no_only_value()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=}}', "Explicit short description")
end

function p:test__no_prefer_value()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|prefer=}}', "Explicit short description")
end

function p:test__no_objectify_alarm_value()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|objectify_alarm=}}', '<span style="color:#d33">[[Module:GetShortDescription]] requires a page name (including namespace).</span>[[Category:Pages displaying alarming messages about Module:GetShortDescription]]', {nowiki = 1})
end

--[[ nonexistent page name ]]

function p:test__nonexistent_page_name()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/nonexistent page}}', '')
end

--[[ unknown param offered ]]

function p:test__unknown_param_with_no_value_offered()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|unknown=}}', "Explicit short description")
end

function p:test__unknown_param_with_value_offered()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|unknown=unknown}}', "Explicit short description")
end

--[[ unknown param found ]]

function p:test__unknown_param_found()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description with unknown params}}', "Explicit short description with unknown params")
end

function p:test__complex_unknown_params_found()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description with complex unknown params}}', "Explicit short description with complex unknown params")
end

--[[ multiple short descriptions ]]

--[[ temporarily disabled re other solution required

function p:test__two_short_descriptions_numbered_after()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short descriptions numbered after}}', "Explicit short description numbered second (used)")
end

function p:test__two_short_descriptions_numbered_before()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short descriptions numbered before}}', "Explicit short description unnumbered second (used)")
end

]]

function p:test__two_short_description_templates()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short description templates}}', "Explicit short description second (used)")
end

function p:test__two_short_description_templates__first_noreplace()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short description templates first noreplace}}', "Explicit short description second (used)")
end

function p:test__two_short_description_templates__second_noreplace()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/two explicit short description templates second noreplace}}', "Explicit short description first (used)")
end

function p:test__three_short_description_templates__second_noreplace()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/three explicit short description templates second noreplace}}', "Explicit short description third (used)")
end

function p:test__three_short_description_templates__second_none__third_noreplace()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/three explicit short description templates second none third noreplace}}', "")
end

--[[ none but name ]]

function p:test__explicit_exists__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description}}', "Explicit short description")
end

function p:test__explicit_does_not_exist__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description}}', "")
end

function p:test__explicit_exists__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia}}', "Free multilingual, online, crowdsourced encyclopedia")
end

function p:test__explicit_does_not_exist__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example}}', "")
end

--[[ name and only ]]

function p:test__only_explicit__explicit_exists__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=explicit}}', "Explicit short description")
end

function p:test__only_wikidata__explicit_exists__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=wikidata}}', "")
end

function p:test__only_explicit__explicit_does_not_exist__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit}}', "")
end

function p:test__only_wikidata__explicit_does_not_exist__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|only=wikidata}}', "")
end

function p:test__only_explicit__explicit_exists__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|only=explicit}}', "Free multilingual, online, crowdsourced encyclopedia")
end

function p:test__only_wikidata__explicit_exists__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|only=wikidata}}', "free multilingual online encyclopedia")
end

function p:test__only_explicit__explicit_does_not_exist__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|only=explicit}}', "")
end

function p:test__only_wikidata__explicit_does_not_exist__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|only=wikidata}}', "Wikimedia disambiguation page")
end

--[[ name and prefer ]]

function p:test__prefer_explicit__explicit_exists__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|prefer=explicit}}', "Explicit short description")
end

function p:test__prefer_wikidata__explicit_exists__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|prefer=wikidata}}', "Explicit short description")
end

function p:test__prefer_explicit__explicit_does_not_exist__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|prefer=explicit}}', "")
end

function p:test__prefer_wikidata__explicit_does_not_exist__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|prefer=wikidata}}', "")
end

function p:test__prefer_explicit__explicit_exists__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|prefer=explicit}}', "Free multilingual, online, crowdsourced encyclopedia")
end

function p:test__prefer_wikidata__explicit_exists__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|prefer=wikidata}}', "free multilingual online encyclopedia")
end

function p:test__prefer_explicit__explicit_does_not_exist__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|prefer=explicit}}', "")
end

function p:test__prefer_wikidata__explicit_does_not_exist__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|prefer=wikidata}}', "Wikimedia disambiguation page")
end

--[[ conflicting params ]]
--[[ only=explicit and prefer=wikidata ]]

function p:test__conflicting__only_explicit__prefer_wikidata__explicit_exists__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=explicit|prefer=wikidata}}', "Explicit short description")
end

function p:test__conflicting__only_explicit__prefer_wikidata__explicit_does_not_exist__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit|prefer=wikidata}}', "")
end

function p:test__conflicting__only_explicit__prefer_wikidata__explicit_exists__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|only=explicit|prefer=wikidata}}', "Free multilingual, online, crowdsourced encyclopedia")
end

function p:test__conflicting__only_explicit__prefer_wikidata__explicit_does_not_exist__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|only=explicit|prefer=wikidata}}', "")
end

--[[ only=wikidata and prefer=explicit ]]

function p:test__conflicting__only_wikidata__prefer_explicit__explicit_exists__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description|only=wikidata|prefer=explicit}}', "")
end

function p:test__conflicting__only_wikidata__prefer_explicit__explicit_does_not_exist__wikidata_does_not_exist()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/no explicit short description|only=wikidata|prefer=explicit}}', "")
end

function p:test__conflicting__only_wikidata__prefer_explicit__explicit_exists__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Wikipedia|only=wikidata|prefer=explicit}}', "free multilingual online encyclopedia")
end

function p:test__conflicting__only_wikidata__prefer_explicit__explicit_does_not_exist__wikidata_exists()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example|only=wikidata|prefer=explicit}}', "Wikimedia disambiguation page")
end

--[[ unusual explicit descriptions ]]

function p:test__only_explicit__undefined()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description undefined|only=explicit}}', "")
end

function p:test__only_explicit__empty()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description empty|only=explicit}}', "")
end

function p:test__only_explicit__none()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description none|only=explicit}}', "")
end

function p:test__only_explicit__numbered()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description numbered|only=explicit}}', "Explicit short description numbered")
end

function p:test__only_explicit__complex()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex|only=explicit}}', "Explicit short description complex")
end

function p:test__only_explicit__complex__numbered()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex numbered|only=explicit}}', "Explicit short description complex numbered")
end

function p:test__only_explicit__numbered__empty()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description numbered empty|only=explicit}}', "")
end

function p:test__only_explicit__numbered__none()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description numbered none|only=explicit}}', "")
end

function p:test__only_explicit__complex__empty()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex empty|only=explicit}}', "")
end

function p:test__only_explicit__complex__none()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex none|only=explicit}}', "")
end

function p:test__only_explicit__complex__numbered__empty()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex numbered empty|only=explicit}}', "")
end

function p:test__only_explicit__complex__numbered__none()
	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=User:Fred Gandt/sandbox/explicit short description complex numbered none|only=explicit}}', "")
end

--[[ test the test; sanity check; should fail ]]

--function p:test__the_test()
--	self:preprocess_equals('{{#invoke:GetShortDescription/sandbox|main|stringify=yes|name=Example}}', "test the test")
--end

--[[ foreign language wikidata ]]

-- Testing |lang_italic= |lang_nocat= |lang_size= |lang_cat= |lang_rtl= |lang_no= will require a wikidata description in a language other than English to be returned

return p