Module:GetShortDescription/testcases

-- 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('', ' Module:GetShortDescription requires a page name (including namespace). ', {nowiki = 1}) end

function p:test__no_name_value self:preprocess_equals('', ' Module:GetShortDescription requires a page name (including namespace). ', {nowiki = 1}) end

function p:test__no_only_value self:preprocess_equals('', "Explicit short description") end

function p:test__no_prefer_value self:preprocess_equals('', "Explicit short description") end

function p:test__no_objectify_alarm_value self:preprocess_equals('', ' Module:GetShortDescription requires a page name (including namespace). ', {nowiki = 1}) end

-- nonexistent page name

function p:test__nonexistent_page_name self:preprocess_equals(, ) end

-- unknown param offered

function p:test__unknown_param_with_no_value_offered self:preprocess_equals('', "Explicit short description") end

function p:test__unknown_param_with_value_offered self:preprocess_equals('', "Explicit short description") end

-- unknown param found

function p:test__unknown_param_found self:preprocess_equals('', "Explicit short description with unknown params") end

function p:test__complex_unknown_params_found self:preprocess_equals('', "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('', "Explicit short description numbered second (used)") end

function p:test__two_short_descriptions_numbered_before self:preprocess_equals('', "Explicit short description unnumbered second (used)") end

]]

function p:test__two_short_description_templates self:preprocess_equals('', "Explicit short description second (used)") end

function p:test__two_short_description_templates__first_noreplace self:preprocess_equals('', "Explicit short description second (used)") end

function p:test__two_short_description_templates__second_noreplace self:preprocess_equals('', "Explicit short description first (used)") end

function p:test__three_short_description_templates__second_noreplace self:preprocess_equals('', "Explicit short description third (used)") end

function p:test__three_short_description_templates__second_none__third_noreplace self:preprocess_equals('', "Explicit short description first (used)") end

-- none but name

function p:test__explicit_exists__wikidata_does_not_exist self:preprocess_equals('', "Explicit short description") end

function p:test__explicit_does_not_exist__wikidata_does_not_exist self:preprocess_equals('', "") end

function p:test__explicit_exists__wikidata_exists self:preprocess_equals('', "Free online crowd-sourced encyclopedia") end

function p:test__explicit_does_not_exist__wikidata_exists self:preprocess_equals('', "Wikimedia disambiguation page") end

-- name and only

function p:test__only_explicit__explicit_exists__wikidata_does_not_exist self:preprocess_equals('', "Explicit short description") end

function p:test__only_wikidata__explicit_exists__wikidata_does_not_exist self:preprocess_equals('', "") end

function p:test__only_explicit__explicit_does_not_exist__wikidata_does_not_exist self:preprocess_equals('', "") end

function p:test__only_wikidata__explicit_does_not_exist__wikidata_does_not_exist self:preprocess_equals('', "") end

function p:test__only_explicit__explicit_exists__wikidata_exists self:preprocess_equals('', "Free online crowd-sourced encyclopedia") end

function p:test__only_wikidata__explicit_exists__wikidata_exists self:preprocess_equals('', "free multilingual online encyclopedia") end

function p:test__only_explicit__explicit_does_not_exist__wikidata_exists self:preprocess_equals('', "") end

function p:test__only_wikidata__explicit_does_not_exist__wikidata_exists self:preprocess_equals('', "Wikimedia disambiguation page") end

-- name and prefer

function p:test__prefer_explicit__explicit_exists__wikidata_does_not_exist self:preprocess_equals('', "Explicit short description") end

function p:test__prefer_wikidata__explicit_exists__wikidata_does_not_exist self:preprocess_equals('', "Explicit short description") end

function p:test__prefer_explicit__explicit_does_not_exist__wikidata_does_not_exist self:preprocess_equals('', "") end

function p:test__prefer_wikidata__explicit_does_not_exist__wikidata_does_not_exist self:preprocess_equals('', "") end

function p:test__prefer_explicit__explicit_exists__wikidata_exists self:preprocess_equals('', "Free online crowd-sourced encyclopedia") end

function p:test__prefer_wikidata__explicit_exists__wikidata_exists self:preprocess_equals('', "free multilingual online encyclopedia") end

function p:test__prefer_explicit__explicit_does_not_exist__wikidata_exists self:preprocess_equals('', "Wikimedia disambiguation page") end

function p:test__prefer_wikidata__explicit_does_not_exist__wikidata_exists self:preprocess_equals('', "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('', "Explicit short description") end

function p:test__conflicting__only_explicit__prefer_wikidata__explicit_does_not_exist__wikidata_does_not_exist self:preprocess_equals('', "") end

function p:test__conflicting__only_explicit__prefer_wikidata__explicit_exists__wikidata_exists self:preprocess_equals('', "Free online crowd-sourced encyclopedia") end

function p:test__conflicting__only_explicit__prefer_wikidata__explicit_does_not_exist__wikidata_exists self:preprocess_equals('', "") end

-- only=wikidata and prefer=explicit

function p:test__conflicting__only_wikidata__prefer_explicit__explicit_exists__wikidata_does_not_exist self:preprocess_equals('', "") end

function p:test__conflicting__only_wikidata__prefer_explicit__explicit_does_not_exist__wikidata_does_not_exist self:preprocess_equals('', "") end

function p:test__conflicting__only_wikidata__prefer_explicit__explicit_exists__wikidata_exists self:preprocess_equals('', "free multilingual online encyclopedia") end

function p:test__conflicting__only_wikidata__prefer_explicit__explicit_does_not_exist__wikidata_exists self:preprocess_equals('', "Wikimedia disambiguation page") end

-- unusual explicit descriptions

function p:test__only_explicit__undefined self:preprocess_equals('', "") end

function p:test__only_explicit__empty self:preprocess_equals('', "") end

function p:test__only_explicit__none self:preprocess_equals('', "none") end

function p:test__only_explicit__numbered self:preprocess_equals('', "Explicit short description numbered") end

function p:test__only_explicit__complex self:preprocess_equals('', "Explicit short description complex") end

function p:test__only_explicit__complex__numbered self:preprocess_equals('', "Explicit short description complex numbered") end

function p:test__only_explicit__numbered__empty self:preprocess_equals('', "") end

function p:test__only_explicit__numbered__none self:preprocess_equals('', "none") end

function p:test__only_explicit__complex__empty self:preprocess_equals('', "") end

function p:test__only_explicit__complex__none self:preprocess_equals('', "none") end

function p:test__only_explicit__complex__numbered__empty self:preprocess_equals('', "") end

function p:test__only_explicit__complex__numbered__none self:preprocess_equals('', "none") end

-- test the test; sanity check; should fail

--function p:test__the_test --	self:preprocess_equals('', "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