Module:Kinship/testcases
Jump to navigation
Jump to search
CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules
Lua
Documentation for this module may be created at Module:Kinship/testcases/doc
Code
local p = require('Module:UnitTests')
function p:test_1_module_against_old_template()
self:preprocess_equals_preprocess_many(
'{{#invoke:Kinship|kinship|','}}',
'{{Kinship|','}}', {
{'mother|Adam Mickiewicz|pl=Adama Mickiewicza'},
{'partner|Frans Pourbus (I)'},
{'son |Frans Pourbus (I)'}, -- whitespace to trim
{'son|Frans Pourbus (I) |link type=-'},
-- not implemented in the old [[Template:Kinship]] (2017-09-09):
-- link should be suppressable
{'brother|Joseph Johnson |link=Category:Joseph Johnson (publisher)'},
{'son|Pavel Ivanovich Chichikov'},
{'foo|foobar'},
})
end
function p:test_2_module_against_old_template_multilanguage()
local testLang = {'es','en','fr','pl'}
for i=1,#testLang,1 do
local lang = testLang[i]
self:preprocess_equals_preprocess_many(
'{{#invoke:Kinship|kinship|','|lang='.. lang ..'}}',
'{{Kinship|','|lang='.. lang ..'}}', {
{'mother|Adam Mickiewicz|pl=Adama Mickiewicza'},
{'spouse|Pavel Ivanovich Chichikov'},
})
end
end
function p:test_3_module_against_wikitext()
self:preprocess_equals_many("{{#invoke:Kinship|kinship|","}}",{
{'item=Q6530', 'not yet decided what to expect'},
{'item=Q6530|itemrelations=father', 'not yet decided what to expect'},
{'item=Q6530|itemrelations=mother', 'not yet decided what to expect'},
{'item=Q6530|itemrelations=parent', 'not yet decided what to expect'}, -- type of relation not defined in [[Template:Kinship/labels]]
{'item=Q6530|itemrelations=cousin', 'not yet decided what to expect'}, -- type of relation not defined in [[Template:Kinship/labels]]
{'item=Q6530|itemrelations=Q23009870', 'not yet decided what to expect'}, -- type indication with QID: Q23009870 is 'cousin'
{'item=Q6530|itemrelations=Q76666', 'not yet decided what to expect'}, -- Q76666 is 'first cousin'
{'item=Q5580|itemrelations=spouse,brother', 'not yet decided what to expect'}, -- >1 types with QID
{'item=Q5580|itemrelations=spouse, sister', 'not yet decided what to expect'}, -- space and wrong assumed gender of subject
{'item=Q5580|itemrelations=P22', 'not yet decided what to expect'}, -- type indication with PID
{'item=Q5580|itemrelations=P22, P25, P26, P40', 'not yet decided what to expect'}, -- >1 types with PID
-- linking: possible values (cf. [[Template:Label/doc]]): 'wikipedia', 'wikidata', 'commons', '-'
-- TODO: there should be more advanced possibilities: commons category, fallback lines and language selection. yet implemented somewhere?
{'item=Q5580|itemrelations=father|link type=commons', 'not yet decided what to expect'},
{'item=Q5580|itemrelations=father|link type=commons category', 'not yet decided what to expect'},
{'item=Q5580|itemrelations=father|link type=wikidata', 'not yet decided what to expect'},
{'item=Q5580|itemrelations=spouse|dates=yes', 'not yet decided what to expect'} --
})
end
return p