Module:Wikidata Infobox/testcases

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Lua

CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules

no documentation yet

Code

-- Unit tests for [[Module:Wikidata Infobox]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:_test_autoMapZoom()
    self:preprocess_equals_many('{{#invoke:Wikidata Infobox | autoMapZoom | ', '}}', 
    	{{'0.1', '15'}, {'1', '14'},  {'10', '12'}, {'100', '9'}, {'1000', '8'}, 
    	 {'10000', '7'}, {'100000', '5'}, {'1000000', '4'}, {'10000000', '2'}})
end

function p:_test_langDirection()
	RTL = {'ar','arc','arz','azb','bcc','ckb','bgn','bqi','dv','fa','glk','he','kk-arab','kk-cn','ks','ku-arab','mzn','pnb','ps','sd','ug','ur','yi'}
	LTR = {'en','pl', 'de', 'kk', 'ru'}
	for _, lang in ipairs(RTL) do
		self:preprocess_equals('{{#invoke:Wikidata Infobox | langDirection | '..lang..'}}', 'rtl')
	end
	for _, lang in ipairs(LTR) do
		self:preprocess_equals('{{#invoke:Wikidata Infobox | langDirection | '..lang..'}}', 'ltr')
	end
end

function p:test_stripDiacrits()
    self:preprocess_equals_many('{{#invoke:Wikidata Infobox | stripDiacrits | ', '}}', 
    	{{'łąkę', 'lake'}, {'część', 'czesc'},  {'Zażółć gęślą jaźń', 'Zazolc gesla jazn'}, {'mäkčeň', 'makcen'}})
end

return p