Module:Annotated link/testcases
Appearance
![]() | This is the test cases page for the module Module:Annotated link. Results of the test cases. |
-- Unit tests for [[Module:AnnotatedLink]]. 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:no_name_param()
self:preprocess_equals('{{#invoke:AnnotatedLink|main}}', "ERROR with invocation of Module:AnnotatedLink: a page name (including namespace) MUST be provided")
end
function p:no_name_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=}}', "ERROR with invocation of Module:AnnotatedLink: a page name (including namespace) MUST be provided")
end
function p:no_display_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|display=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_quote_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|quote=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_abbr_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|abbr=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_abbr_value__abbr_title()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|abbr=|abbr_title=Abbreviation}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_abbr__no_abbr_title_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|abbr=|abbr_title=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_aka_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|aka=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_wedge_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|wedge=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_dash_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|dash=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_desc_first_letter_case_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|desc_first_letter_case=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_link_lang_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|link_lang=}}', "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:no_aka_lang_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|aka_lang=}}', "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:no_wedge_lang_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|wedge_lang=}}', "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:no_only_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|only=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_prefer_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|prefer=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:no_fallback_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/no explicit short description|fallback=}}', "User:Fred Gandt/sandbox/no explicit short description")
end
--[[ unknown param ]]
function p:no_unknown_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|unknown=}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:unknown_value()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|unknown=unknown}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
--[[ none but name ]]
function p:explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description}}', "User:Fred Gandt/sandbox/explicit short description – explicit short description")
end
function p:explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/no explicit short description}}', "User:Fred Gandt/sandbox/no explicit short description")
end
function p:explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Wikipedia}}', "Wikipedia – Free multilingual, online, crowdsourced encyclopedia")
end
function p:explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Example}}', "Example – Wikimedia disambiguation page")
end
--[[ name and display ]]
function p:display__explicit_exists__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|display=Test page}}', "Test page – explicit short description")
end
function p:display__explicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/no explicit short description|display=Test page}}', "Test page")
end
function p:display__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Wikipedia|display=Article about Wikipeda}}', "Article about Wikipeda – Free multilingual, online, crowdsourced encyclopedia")
end
function p:display__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Example|display=Example disambiguation page}}', "Example disambiguation page – Wikimedia disambiguation page")
end
--[[ ]]
--[[
|name= |display= |quote= |abbr= |abbr_title= |aka= |wedge= |dash= |desc_first_letter_case=
|link_lang= |link_lang_italic= |link_lang_nocat= |link_lang_size= |link_lang_cat= |link_lang_rtl=
|aka_lang= |aka_lang_italic= |aka_lang_nocat= |aka_lang_size= |aka_lang_cat= |aka_lang_rtl=
|wedge_lang= |wedge_lang_italic= |wedge_lang_nocat= |wedge_lang_size= |wedge_lang_cat= |wedge_lang_rtl=
|only= |prefer= |fallback=
|desc_lang_italic= |desc_lang_nocat= |desc_lang_size= |desc_lang_cat= |desc_lang_rtl= |desc_lang_no=
]]
--[[ test the test ]]
function p:test_the_test()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Example}}', "test the test")
end
return p