Přeskočit na obsah

Modul:Wikidata/testcases

Z Wikicest

Dokumentaci tohoto modulu lze vytvořit na stránce Modul:Wikidata/testcases/Dokumentace

-- Click talk page to run tests
local p = require 'Modul:UnitTests'

local function test_wd_class(left, right, expected)
	p:preprocess_equals(left .. '|addclass=true' .. right, mw.ustring.format('<span class="wd">%s</span>', expected))
end

function p:test_get_label()
	self:preprocess_equals_many('{{#invoke:Wikidata|getLabel|id=Q1085', '}}', {
		{'', 'Praha'},
		{'|lang=cs', 'Praha'},
		{'|lang=ru', 'Прага'},
		{'|lang=xyz', ''},
	})
	test_wd_class('{{#invoke:Wikidata|getLabel|id=Q1085', '}}', 'Praha')
end

function p:test_get_description()
	self:preprocess_equals('{{#invoke:Wikidata|getDescription|id=Q1085}}', mw.wikibase.description('Q1085'))
	test_wd_class('{{#invoke:Wikidata|getDescription|id=Q1085', '}}', mw.wikibase.description('Q1085'))
end

function p:test_get_sitelink()
	self:preprocess_equals_many('{{#invoke:Wikidata|getSitelink|id=Q1085', '}}', {
		{'', 'Praha'},
		{'', mw.wikibase.sitelink('Q1085')},
		{'|cswiki', 'Praha'},
		{'|site=cswiki', 'Praha'},
		{'|site=ruwiki|pattern=[[:ru:$1]]', '[[:ru:Прага]]'},
	})
	test_wd_class('{{#invoke:Wikidata|getSitelink|id=Q1085|cswiki', '}}', 'Praha')
end

function p:test_get_badges()
	self:preprocess_equals_many('{{#invoke:Wikidata|getBadges|id=', '}}', {
		{'Q45909|site=cswiki', mw.wikibase.label('Q17437796')},
		{'Q189080|site=cswiki', mw.wikibase.label('Q17437798')},
		{'Q1085|site=foowiki', ''},
	})
end

function p:test_get_id()
	self:preprocess_equals('{{Položka|Modul:Wikidata/Dokumentace|Spolková republika Německo}}', 'Q183')
end
--[[
function p:test_get_count()
	
end

function p:test_format_statements()
	
end
]]
return p