Module:Plain sister/sandbox testcases
Appearance
-- Unit tests for [[Module:Plain sister]]. Go to the talk page to view test results.
local testSuit = require('Module:UnitTests')
local PS = require('Module:Plain sister/sandbox')
-- test the core getLinks functions
function testSuit:test_getLinks()
self:equals_deep(
'From Wikidata: Q1',
PS.getLinks({
wikidata = 'Q1',
}),
{
w = 'Universe',
['c:Category'] = 'Universe',
q = 'Universe',
v = 'Universe',
d = 'Q1',
}
)
self:equals_deep(
'From an edition (Stella Dallas)',
PS.getLinks({
wikidata = 'Q106388874',
}),
{
w = 'Stella Dallas (novel)', -- from the work
['c:Category'] = 'Stella Dallas (1923 edition of novel)', -- from the edition
d = 'Q106388874',
}
)
-- A topic
self:equals_deep(
'A topic via P921',
PS.getLinks({
wikidata = 'Q19064858',
}),
{
w = 'Banksia spinulosa',
wikispecies = 'Banksia spinulosa',
d = 'Q19064858',
}
)
-- An author.
self:equals_deep(
'Author',
PS.getLinks({
wikidata = 'Q15712330',
}),
{
w = 'Alice Hay Wadsworth',
['c:Category'] = 'Alice Wadsworth', -- from the edition
d = 'Q15712330',
}
)
-- A biographical article
-- should NOT include the commons category via the P921 claim
self:equals_deep(
'Biographical article',
PS.getLinks({
wikidata = 'Q84635865',
}),
{
w = 'William Adams (pilot)',
d = 'Q84635865',
}
)
end
function testSuit:test_inline()
local prefix = '<li class="sisitem"><span class="sisicon" style="padding-right:1ex;">[[Image:Wikimedia-logo.svg|frameless|18px|link=Special:sitematrix|alt=Sister Projects.]]</span>[[Special:sitematrix|sister projects]]: '
-- Not a Wikisource item.
self:preprocess_equals(
'{{#invoke:Plain sister/sandbox|interprojectPart|wikidata=Q1}}',
prefix .. '[[w:Universe|Wikipedia article]], [[c:Category:Universe|Commons category]], [[q:Universe|quotes]], [[v:Universe|course]], [[d:Q1|Wikidata item]].</li>',
{nowiki=1}
)
-- Wikisource edition, via template.
self:preprocess_equals(
'{{Plain sister/sandbox|wikidata=Q23308118}}',
'<ul id="plainSister" style="display:inline-block; font-size:93%; line-height:normal; list-style-type:none; list-style-image:none; list-style-position:outside;'
.. ' border:1px solid #AAA; float:right; clear:right; margin:0.5ex 0.5ex 0.5ex 0.5ex; padding:0.0ex 0.0ex 0.0ex 0.0ex; background:#FFFFFF; background-color:#FFFFFF;">'
.. prefix .. '[[w:The Nether World|Wikipedia article]], [[c:Category:The Nether World (novel)|Commons category]], [[d:Q23308118|Wikidata item]].</li></ul>',
{nowiki=1}
)
end
return testSuit