Module:Annotated link/testcases: Difference between revisions

Content deleted Content added
rudimentary tests for template_link; I need some reliable "fake" templates with various {{short descriptions}} to thoroughly test
+ a bunch of  s
Line 15:
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
Line 57:
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
Line 63:
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
Line 69:
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
Line 83:
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
function p:test__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|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
Line 93:
 
function p:test__short_description_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description}}', "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]]  – explicit short description")
end
 
Line 121:
 
function p:test__display__short_description_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|display=Test page}}', "[[:User:Fred Gandt/sandbox/explicit short description|Test page]]  – explicit short description")
end
 
Line 131:
 
function p:test__quote__short_description_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|quote=yes}}', '"[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]]"  – explicit short description')
end
 
Line 141:
 
function p:test__abbr__short_description_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|abbr=ESD}}', '[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]] (<abbr>ESD</abbr>) &nbsp;– explicit short description', { combined = 1 })
end
 
Line 151:
 
function p:test__abbr__abbr_title__short_description_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|abbr=ESD|abbr_title=Explicit Short Description}}', '[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]] (<abbr title="Explicit Short Description">ESD</abbr>) &nbsp;– explicit short description', { combined = 1 })
end
 
Line 161:
 
function p:test__aka__short_description_exists()
self:preprocess_equals("{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|aka=Fred's test page}}", "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]], also known as Fred's test page &nbsp;– explicit short description")
end
 
Line 171:
 
function p:test__wedge__short_description_exists()
self:preprocess_equals("{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|wedge=[[Tight Fit]]}}", "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]], [[Tight Fit]] &nbsp;– explicit short description")
end
 
Line 181:
 
function p:test__abbr__aka__short_description_exists()
self:preprocess_equals("{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|abbr=ESD|aka=Fred's test page}}", "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]] (<abbr>ESD</abbr>), also known as Fred's test page &nbsp;– explicit short description", { combined = 1 })
end
 
Line 191:
 
function p:test__abbr__wedge__short_description_exists()
self:preprocess_equals("{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|abbr=ESD|wedge=[[Tight Fit]]}}", "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]] (<abbr>ESD</abbr>), [[Tight Fit]] &nbsp;– explicit short description", { combined = 1 })
end
 
Line 201:
 
function p:test__abbr__aka__wedge__short_description_exists()
self:preprocess_equals("{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|abbr=ESD|aka=Fred's test page|wedge=[[Tight Fit]]}}", "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]] (<abbr>ESD</abbr>), also known as Fred's test page, [[Tight Fit]] &nbsp;– explicit short description", { combined = 1 })
end
 
Line 211:
 
function p:test__aka__wedge__short_description_exists()
self:preprocess_equals("{{#invoke:AnnotatedLink|main|name=User:Fred Gandt/sandbox/explicit short description|aka=Fred's test page|wedge=[[Tight Fit]]}}", "[[:User:Fred Gandt/sandbox/explicit short description|User:Fred Gandt/sandbox/explicit short description]], also known as Fred's test page, [[Tight Fit]] &nbsp;– explicit short description")
end
 
Line 259:
 
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]] &nbsp;– Explicit short description")
end
 
Line 267:
 
function p:test__only_explicit__explicit_exists()
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]] &nbsp;– explicit short description")
end
 
Line 277:
 
function p:test__only_wikidata__wikidata_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Wikipedia|only=wikidata}}', "[[:Wikipedia|Wikipedia]] &nbsp;– free multilingual online encyclopedia")
end
 
Line 287:
 
function p:test__only_explicit__explicit_exists__wikidata_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Wikipedia|prefer=explicit}}', "[[:Wikipedia|Wikipedia]] &nbsp;– 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]] &nbsp;– wikimedia disambiguation page")
end
 
Line 297:
 
function p:test__only_wikidata__wikidata_exists__explicit_exists()
self:preprocess_equals('{{#invoke:AnnotatedLink|main|name=Wikipedia|prefer=wikidata}}', "[[:Wikipedia|Wikipedia]] &nbsp;– 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]] &nbsp;– explicit short description")
end
 
Line 307:
 
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]] &nbsp;– 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]] &nbsp;– fallback")
end