Module:Annotated link/testcases: Difference between revisions

Content deleted Content added
mixed language test
I think that's everything within reason
Line 236:
end
 
function p:test__dash_value_comma()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|dash=,}}', "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]], explicit short description")
end
 
function p:test__desc_first_letter_case_upper()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|desc_first_letter_case=upper}}', "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]] – Explicit short description")
end
 
--[[ basic passthrough to Module:GetShortDescription ]]
--[[
 
--[[ only explicit ]]
|name= |display= |quote= |abbr= |abbr_title= |aka= |wedge= |dash= |desc_first_letter_case=
 
function p:test__only_explicit__explicit_exists()
|link_lang= |link_lang_italic= |link_lang_nocat= |link_lang_size= |link_lang_cat= |link_lang_rtl=
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|only=explicit}}', "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]] – explicit short description")
end
 
function p:test__only_explicit__explicit_does_not_exist()
|aka_lang= |aka_lang_italic= |aka_lang_nocat= |aka_lang_size= |aka_lang_cat= |aka_lang_rtl=
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit}}', "[[:User:Fred Gandt/sandbox/no explicit short description|User:Fred Gandt/sandbox/no explicit short description]]")
end
 
--[[ only wikidata ]]
|wedge_lang= |wedge_lang_italic= |wedge_lang_nocat= |wedge_lang_size= |wedge_lang_cat= |wedge_lang_rtl=
 
function p:test__only_wikidata__wikidata_exists()
|only= |prefer= |fallback=
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Wikipedia|only=wikidata}}', "[[:Wikipedia|Wikipedia]] – free multilingual online encyclopedia")
end
 
function p:test__only_wikidata__wikidata_does_not_exist()
|desc_lang_italic= |desc_lang_nocat= |desc_lang_size= |desc_lang_cat= |desc_lang_rtl= |desc_lang_no=
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|only=wikidata}}', "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]]")
end
 
--[[ prefer explicit ]]
]]
 
function p:test__only_explicit__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Wikipedia|prefer=explicit}}', "[[:Wikipedia|Wikipedia]] – Free multilingual, online, crowdsourced encyclopedia")
end
 
function p:test__only_explicit__explicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Example|prefer=explicit}}', "[[:Example|Example]] – Wikimedia disambiguation page")
end
 
--[[ prefer wikidata ]]
 
function p:test__only_wikidata__wikidata_exists__explicit_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Wikipedia|prefer=wikidata}}', "[[:Wikipedia|Wikipedia]] – free multilingual online encyclopedia")
end
 
function p:test__only_wikidata__wikidata_does_not_exist__explicit_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|prefer=wikidata}}', "[[:User:Fred Gandt/sandbox/explicit short description|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('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit|fallback=fallback}}', "[[:User:Fred Gandt/sandbox/no explicit short description|User:Fred Gandt/sandbox/no explicit short description]] – fallback")
end
 
function p:test__only_wikidata__fallback__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|only=wikidata|fallback=fallback}}', "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]] – fallback")
end
 
--[[ test the test; sanity check; should fail ]]
Line 259 ⟶ 301:
-- self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Example}}', "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