Module:GetShortDescription/testcases: Difference between revisions

Content deleted Content added
+ more tests
this is more work that writing the module in the first place
Line 4:
local p = require('Module:UnitTests')
 
function p:test_name__explicit_existsno_name_param()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=The Partisan}}', "1943ERROR songwith byinvocation Annaof MarlyModule:GetShortDescription: anda Emmanuelpage d'Astier, popularisedname by(including Leonardnamespace) CohenMUST inbe 1969provided")
end
 
function p:test_name__explicit_does_not_existno_name_value()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)}}', "episodeERROR with invocation of Star TrekModule:GetShortDescription: Voyagera page name (S7including E20namespace) MUST be provided")
end
 
function p:test_name_only_explicit__explicit_existsexplicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=TheUser:Fred Partisan|only=Gandt/sandbox/explicit short description}}', "1943 song by Anna Marly and Emmanuel d'Astier, popularised by Leonard Cohenexplicit inshort 1969description")
end
 
function p:test_name_only_explict__explicit_does_not_existexplicit_does_not_exist__wikidata_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)|only=explicitExample}}', "Wikimedia disambiguation page")
end
 
function p:test_name_only_wikidataexplicit_does_not_exist__wikidata_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=User:Fred Gandt/sandbox/no explicit short description}}', "")
end
 
function p:only_explicit__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=User:Fred Gandt/sandbox/explicit short description|only=explicit}}', "explicit short description")
end
 
function p:only_explict__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=User:Fred Gandt/sandbox/no explicit short description|only=explicit}}', "")
end
 
function p:only_wikidata()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=The Partisan|only=wikidata}}', "song composed by Anna Marly with lyrics by Emmanuel d'Astier de La Vigerie performed by Leonard Cohen")
end
 
function p:test_name_prefer_explicit__explicit_existsprefer_explicit__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=The Partisan|prefer=explicit}}', "1943 song by Anna Marly and Emmanuel d'Astier, popularised by Leonard Cohen in 1969")
end
 
function p:test_name_prefer_explicit__explicit_does_not_existprefer_explicit__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)|prefer=explicit}}', "episode of Star Trek: Voyager (S7 E20)")
end
 
function p:test_name_prefer_wikidata__explicit_existsprefer_wikidata__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=The Partisan|prefer=wikidata}}', "song composed by Anna Marly with lyrics by Emmanuel d'Astier de La Vigerie performed by Leonard Cohen")
end
 
function p:test_name_prefer_wikidata__explicit_does_not_existprefer_wikidata__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)|prefer=wikidata}}', "episode of Star Trek: Voyager (S7 E20)")
end
 
function p:conflicting__only_explicit_prefer_wikidata__explicit_exists()
function p:test_name__conflicting__only_explicit_prefer_wikidata__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=The Partisan|prefer=wikidata|only=explicit}}', "1943 song by Anna Marly and Emmanuel d'Astier, popularised by Leonard Cohen in 1969")
end
 
function p:conflicting__only_wikidata_prefer_explicit__explicit_exists()
function p:test_name__conflicting__only_wikidata_prefer_explicit__explicit_exists()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=The Partisan|prefer=explicit|only=wikidata}}', "song composed by Anna Marly with lyrics by Emmanuel d'Astier de La Vigerie performed by Leonard Cohen")
end
 
function p:conflicting__only_explicit_prefer_wikidata__explicit_does_not_exist()
function p:test_name__conflicting__only_explicit_prefer_wikidata__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)|prefer=wikidata|only=explicit}}', "")
end
 
function p:conflicting__only_wikidata_prefer_explicit__explicit_does_not_exist()
function p:test_name__conflicting__only_wikidata_prefer_explicit__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)|prefer=explicit|only=wikidata}}', "episode of Star Trek: Voyager (S7 E20)")
end
 
function p:test_name_only_explict_fallback__explicit_existsonly_explict_fallback__explicit_exists()
self:preprocess_equals("{{#invoke:GetShortDescription|main|name=The Partisan|only=explicit|fallback=a song by Anna Marly and Emmanuel d'Astier}}", "1943 song by Anna Marly and Emmanuel d'Astier, popularised by Leonard Cohen in 1969")
end
 
function p:only_explict_fallback__explicit_does_not_exist()
function p:test_name_only_explict_fallback__explicit_does_not_exist()
self:preprocess_equals('{{#invoke:GetShortDescription|main|name=Author, Author (Star Trek: Voyager)|only=explicit|fallback=an episode of Star Trek: Voyager}}', "an episode of Star Trek: Voyager")
end