Module:Wikidata Infobox/sandbox/testcases

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Lua
CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules

Documentation for this module may be created at Module:Wikidata Infobox/sandbox/testcases/doc

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/sandbox | 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/sandbox | langDirection | '..lang..'}}', 'rtl')
	end
	for _, lang in ipairs(LTR) do
		self:preprocess_equals('{{#invoke:Wikidata Infobox/sandbox | langDirection | '..lang..'}}', 'ltr')
	end
	self:preprocess_equals('{{#invoke:Wikidata Infobox/sandbox | langDirection }}', 'ltr')
end

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

return p