Module:Commons link/testcases
Appearance
![]() | This is the test cases page for the module Module:Commons link. Results of the test cases. |
local p = require('Module:UnitTests')
function p:testGallery()
-- known link
self:preprocess_equals('{{#invoke:Commons link| getGallery | Mount Whitney}}',
'[[Commons:Mount Whitney|Mount Whitney]]')
-- known link with linktext
self:preprocess_equals('{{#invoke:Commons link| getGallery | Mount Whitney |linktext=Big Mountain}}',
'[[Commons:Mount Whitney|Big Mountain]]')
-- search for string
self:preprocess_equals('{{#invoke:Commons link| getGallery | search=Mount Whitney}}',
'[[Commons:Special:Search/Mount Whitney|Mount Whitney]]')
-- search for string + linktext
self:preprocess_equals('{{#invoke:Commons link| getGallery | search=Mount Whitney |linktext=Big Mountain}}',
'[[Commons:Special:Search/Mount Whitney|Big Mountain]]')
-- P935 matches sitelink
self:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q2217963}}',
'[[Commons:Samuel Baker House|Samuel Baker House]]')
-- P935 matches sitelink + linktext
self:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q2217963 |linktext=Big House}}',
'[[Commons:Samuel Baker House|Big House]]')
-- sitelink only
self:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q816044}}',
'[[Commons:Bellows Falls, Vermont|Bellows Falls, Vermont]]')
-- sitelink + linktext
self:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q816044|linktext=Little Town}}',
'[[Commons:Bellows Falls, Vermont|Little Town]]')
-- sitelink and P935 inconsistent
self:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q139289}}',
'[[Commons:Special:Search/Boeing 737 MAX|Boeing 737 MAX]]')
-- sitelink and P935 inconsistent + linktext
self:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q139289|linktext=Not a plane}}',
'[[Commons:Special:Search/Boeing 737 MAX|Not a plane]]')
-- no sitelink or P935
self:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q29017978}}',
'[[Commons:Special:Search/Bell FCX-001|Bell FCX-001]]')
-- no sitelink or P935, but linktext
self:preprocess_equals('{{#invoke:Commons link| getGallery | qid=Q29017978|linktext=Medium Helicopter}}',
'[[Commons:Special:Search/Bell FCX-001|Medium Helicopter]]')
end
function p:testCategory()
-- known link
self:preprocess_equals('{{#invoke:Commons link| getCategory | Mount Whitney}}',
'[[Commons:Category:Mount Whitney|Mount Whitney]]')
-- known link with linktext
self:preprocess_equals('{{#invoke:Commons link| getCategory | Mount Whitney |linktext=Big Mountain}}',
'[[Commons:Category:Mount Whitney|Big Mountain]]')
-- search for string
self:preprocess_equals('{{#invoke:Commons link| getCategory | search=Mount Whitney}}',
'[[Commons:Special:Search/Category:Mount Whitney|Mount Whitney]]')
-- search for string + linktext
self:preprocess_equals('{{#invoke:Commons link| getCategory | search=Mount Whitney |linktext=Big Mountain}}',
'[[Commons:Special:Search/Category:Mount Whitney|Big Mountain]]')
-- P373 matches sitelink
self:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2601154}}',
'[[Commons:Category:Agama lionotus|Agama lionotus]]')
-- P373 matches sitelink + linktext
self:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2601154|linktext=Small Lizard}}',
'[[Commons:Category:Agama lionotus|Small Lizard]]')
-- P910 matches P373
self:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q853037}}',
'[[Commons:Category:Bánhida|Bánhida]]')
-- P910 matches P373 + linktext
self:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q853037|linktext=Old Neighborhood}}',
'[[Commons:Category:Bánhida|Old Neighborhood]]')
-- missing data
self:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2963317}}',
'[[Commons:Special:Search/Category:Chicago Lawn, Chicago|Chicago Lawn, Chicago]]')
-- missing data + linktext
self:preprocess_equals('{{#invoke:Commons link| getCategory | qid=Q2963317|linktext=Big Neighborhood}}',
'[[Commons:Special:Search/Category:Chicago Lawn, Chicago|Big Neighborhood]]')
end
return p