Module:Pagetype/testcases
Yi palo
Documentation for this module may be created at Module:Pagetype/testcases/doc
-- Unit tests for [[Module:Pagetype]]. Click talk page to run tests.
local mPageType = require('Module:Pagetype/sandbox')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local mMockTitle = require('Module:Mock title')
local mTemplateInvocation = require('Module:Template invocation')
local suite = ScribuntoUnit:new()
mMockTitle.registerMockTitles(
{title = 'Foo', exists = true, isRedirect = true, redirectTarget = 'Foobar'},
{title = 'Talk:Foo', exists = true, isRedirect = false},
{title = 'UK', exists = true, isRedirect = true, redirectTarget = 'United Kingdom'},
{title = 'Talk:UK', exists = true, isRedirect = true, redirectTarget = 'Talk:United Kingdom'},
{title = 'United Kingdom', exists = true, isRedirect = false},
{title = 'Talk:United Kingdom', exists = true, isRedirect = false},
{title = 'User:Example', exists = true, isRedirect = false},
{title = 'User talk:Example', exists = true, isRedirect = false},
{title = 'Wikipedia:Namespace', exists = true, isRedirect = false},
{title = 'Wikipedia talk:Namespace', exists = true, isRedirect = false},
{title = 'File:Example.jpg', exists = true, isRedirect = false},
{title = 'File talk:Example.jpg', exists = true, isRedirect = false},
{title = 'Image:Example.jpg', exists = true, isRedirect = false},
{title = 'Image talk:Example.jpg', exists = true, isRedirect = false},
{title = 'MediaWiki:Watchlist-details', exists = true, isRedirect = false},
{title = 'MediaWiki talk:Spam-blacklist/log', exists = true, isRedirect = false},
{title = 'MediaWiki talk:Watchlist-messages', exists = true, isRedirect = false},
{title = 'Template:Pagetype', exists = true, isRedirect = false},
{title = 'Template talk:Pagetype', exists = true, isRedirect = false},
{title = 'Help:Contents', exists = true, isRedirect = false},
{title = 'Help talk:Contents', exists = true, isRedirect = false},
{title = 'Category:Wikipedians', exists = true, isRedirect = false},
{title = 'Category talk:Wikipedians', exists = true, isRedirect = false},
{title = 'Portal:The arts', exists = true, isRedirect = false},
{title = 'Portal talk:The arts', exists = true, isRedirect = false},
{title = 'Draft:Example', exists = true, isRedirect = false},
{title = 'Draft talk:Example', exists = true, isRedirect = false},
{title = 'TimedText:Foo', exists = true, isRedirect = false},
{title = 'TimedText talk:Foo', exists = true, isRedirect = false},
{title = 'Module:Pagetype/testcases', exists = true, isRedirect = false},
{title = 'Media:Example.jpg', fileExists = true}
)
local tests = {
{
group = 'current page',
args = {},
expected = 'module',
},
{
group = 'current page',
args = {module = 'no'},
expected = 'page',
},
{
group = 'current page',
args = {module = 'foo'},
expected = 'foo',
},
{
group = 'spaces',
args = {module = ' no '},
expected = 'page',
},
{
group = 'spaces',
args = {module = ' foo '},
expected = 'foo',
},
{
group = 'spaces',
args = {page = ' UK ', redirect = ' No '},
expected = 'article',
},
{
group = 'defaults',
args = {page = 'UK'},
expected = 'redirect',
},
{
group = 'defaults',
args = {page = 'Talk:UK'},
expected = 'redirect',
},
{
group = 'defaults',
args = {page = 'United Kingdom'},
expected = 'article',
},
{
group = 'defaults',
args = {page = 'Talk:United Kingdom'},
expected = 'article',
},
{
group = 'defaults',
args = {page = 'User:Example'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'User talk:Example'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Wikipedia:Namespace'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Wikipedia talk:Namespace'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Project:Namespace'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Project talk:Namespace'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'WP:Namespace'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'WT:Namespace'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'File:Example.jpg'},
expected = 'file',
},
{
group = 'defaults',
args = {page = 'File talk:Example.jpg'},
expected = 'file',
},
{
group = 'defaults',
args = {page = 'Image:Example.jpg'},
expected = 'file',
},
{
group = 'defaults',
args = {page = 'Image talk:Example.jpg'},
expected = 'file',
},
{
group = 'defaults',
args = {page = 'MediaWiki:Watchlist-details'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'MediaWiki talk:Watchlist-messages'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Template:Pagetype'},
expected = 'template',
},
{
group = 'defaults',
args = {page = 'Template talk:Pagetype'},
expected = 'template',
},
{
group = 'defaults',
args = {page = 'Help:Contents'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Help talk:Contents'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Category:Wikipedians'},
expected = 'category',
},
{
group = 'defaults',
args = {page = 'Category talk:Wikipedians'},
expected = 'category',
},
{
group = 'defaults',
args = {page = 'Portal:The arts'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Portal talk:The arts'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Draft:Example'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Draft talk:Example'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'TimedText:Foo'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'TimedText talk:Foo'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Special:PrefixIndex'},
expected = 'page',
},
{
group = 'defaults',
args = {page = 'Media:Example.jpg'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'UK', defaultns = 'none'},
expected = 'redirect',
},
{
group = 'defaultns=none',
args = {page = 'Talk:UK', defaultns = 'none'},
expected = 'redirect',
},
{
group = 'defaultns=none',
args = {page = 'United Kingdom', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Talk:United Kingdom', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'User:Example', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'User talk:Example', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Wikipedia:Namespace', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Wikipedia talk:Namespace', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Project:Namespace', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Project talk:Namespace', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'WP:Namespace', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'WT:Namespace', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'File:Example.jpg', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'File talk:Example.jpg', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Image:Example.jpg', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Image talk:Example.jpg', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'MediaWiki:Watchlist-details', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'MediaWiki talk:Watchlist-messages', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Template:Pagetype', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Template talk:Pagetype', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Help:Contents', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Help talk:Contents', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Category:Wikipedians', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Category talk:Wikipedians', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Portal:The arts', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Portal talk:The arts', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Draft:Example', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Draft talk:Example', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'TimedText:Foo', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'TimedText talk:Foo', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Special:PrefixIndex', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=none',
args = {page = 'Media:Example.jpg', defaultns = 'none'},
expected = 'page',
},
{
group = 'defaultns=extended',
args = {page = 'UK', defaultns = 'extended'},
expected = 'redirect',
},
{
group = 'defaultns=extended',
args = {page = 'Talk:UK', defaultns = 'extended'},
expected = 'redirect',
},
{
group = 'defaultns=extended',
args = {page = 'United Kingdom', defaultns = 'extended'},
expected = 'article',
},
{
group = 'defaultns=extended',
args = {page = 'Talk:United Kingdom', defaultns = 'extended'},
expected = 'article',
},
{
group = 'defaultns=extended',
args = {page = 'User:Example', defaultns = 'extended'},
expected = 'user page',
},
{
group = 'defaultns=extended',
args = {page = 'User talk:Example', defaultns = 'extended'},
expected = 'user page',
},
{
group = 'defaultns=extended',
args = {page = 'Wikipedia:Namespace', defaultns = 'extended'},
expected = 'project page',
},
{
group = 'defaultns=extended',
args = {page = 'Wikipedia talk:Namespace', defaultns = 'extended'},
expected = 'project page',
},
{
group = 'defaultns=extended',
args = {page = 'Project:Namespace', defaultns = 'extended'},
expected = 'project page',
},
{
group = 'defaultns=extended',
args = {page = 'Project talk:Namespace', defaultns = 'extended'},
expected = 'project page',
},
{
group = 'defaultns=extended',
args = {page = 'WP:Namespace', defaultns = 'extended'},
expected = 'project page',
},
{
group = 'defaultns=extended',
args = {page = 'WT:Namespace', defaultns = 'extended'},
expected = 'project page',
},
{
group = 'defaultns=extended',
args = {page = 'File:Example.jpg', defaultns = 'extended'},
expected = 'file',
},
{
group = 'defaultns=extended',
args = {page = 'File talk:Example.jpg', defaultns = 'extended'},
expected = 'file',
},
{
group = 'defaultns=extended',
args = {page = 'Image:Example.jpg', defaultns = 'extended'},
expected = 'file',
},
{
group = 'defaultns=extended',
args = {page = 'Image talk:Example.jpg', defaultns = 'extended'},
expected = 'file',
},
{
group = 'defaultns=extended',
args = {page = 'MediaWiki:Watchlist-details', defaultns = 'extended'},
expected = 'interface page',
},
{
group = 'defaultns=extended',
args = {page = 'MediaWiki talk:Watchlist-messages', defaultns = 'extended'},
expected = 'interface page',
},
{
group = 'defaultns=extended',
args = {page = 'Template:Pagetype', defaultns = 'extended'},
expected = 'template',
},
{
group = 'defaultns=extended',
args = {page = 'Template talk:Pagetype', defaultns = 'extended'},
expected = 'template',
},
{
group = 'defaultns=extended',
args = {page = 'Help:Contents', defaultns = 'extended'},
expected = 'help page',
},
{
group = 'defaultns=extended',
args = {page = 'Help talk:Contents', defaultns = 'extended'},
expected = 'help page',
},
{
group = 'defaultns=extended',
args = {page = 'Category:Wikipedians', defaultns = 'extended'},
expected = 'category',
},
{
group = 'defaultns=extended',
args = {page = 'Category talk:Wikipedians', defaultns = 'extended'},
expected = 'category',
},
{
group = 'defaultns=extended',
args = {page = 'Portal:The arts', defaultns = 'extended'},
expected = 'portal',
},
{
group = 'defaultns=extended',
args = {page = 'Portal talk:The arts', defaultns = 'extended'},
expected = 'portal',
},
{
group = 'defaultns=extended',
args = {page = 'Draft:example', defaultns = 'extended'},
expected = 'draft',
},
{
group = 'defaultns=extended',
args = {page = 'Draft talk:example', defaultns = 'extended'},
expected = 'draft',
},
{
group = 'defaultns=extended',
args = {page = 'TimedText:Foo', defaultns = 'extended'},
expected = 'page',
},
{
group = 'defaultns=extended',
args = {page = 'TimedText talk:Foo', defaultns = 'extended'},
expected = 'page',
},
{
group = 'defaultns=extended',
args = {page = 'Special:PrefixIndex', defaultns = 'extended'},
expected = 'page',
},
{
group = 'defaultns=extended',
args = {page = 'Media:Example.jpg', defaultns = 'extended'},
expected = 'page',
},
{
group = 'defaultns=all',
args = {page = 'UK', defaultns = 'all'},
expected = 'redirect',
},
{
group = 'defaultns=all',
args = {page = 'Talk:UK', defaultns = 'all'},
expected = 'redirect',
},
{
group = 'defaultns=all',
args = {page = 'United Kingdom', defaultns = 'all'},
expected = 'article',
},
{
group = 'defaultns=all',
args = {page = 'Talk:United Kingdom', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'User:Example', defaultns = 'all'},
expected = 'user page',
},
{
group = 'defaultns=all',
args = {page = 'User talk:Example', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'Wikipedia:Namespace', defaultns = 'all'},
expected = 'project page',
},
{
group = 'defaultns=all',
args = {page = 'Wikipedia talk:Namespace', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'Project:Namespace', defaultns = 'all'},
expected = 'project page',
},
{
group = 'defaultns=all',
args = {page = 'Project talk:Namespace', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'WP:Namespace', defaultns = 'all'},
expected = 'project page',
},
{
group = 'defaultns=all',
args = {page = 'WT:Namespace', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'File:Example.jpg', defaultns = 'all'},
expected = 'file',
},
{
group = 'defaultns=all',
args = {page = 'File talk:Example.jpg', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'Image:Example.jpg', defaultns = 'all'},
expected = 'file',
},
{
group = 'defaultns=all',
args = {page = 'Image talk:Example.jpg', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'MediaWiki:Watchlist-details', defaultns = 'all'},
expected = 'interface page',
},
{
group = 'defaultns=all',
args = {page = 'MediaWiki talk:Watchlist-messages', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'Template:Pagetype', defaultns = 'all'},
expected = 'template',
},
{
group = 'defaultns=all',
args = {page = 'Template talk:Pagetype', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'Help:Contents', defaultns = 'all'},
expected = 'help page',
},
{
group = 'defaultns=all',
args = {page = 'Help talk:Contents', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'Category:Wikipedians', defaultns = 'all'},
expected = 'category',
},
{
group = 'defaultns=all',
args = {page = 'Category talk:Wikipedians', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'Portal:The arts', defaultns = 'all'},
expected = 'portal',
},
{
group = 'defaultns=all',
args = {page = 'Portal talk:The arts', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'Draft:Example', defaultns = 'all'},
expected = 'draft',
},
{
group = 'defaultns=all',
args = {page = 'Draft talk:Example', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'TimedText:Foo', defaultns = 'all'},
expected = 'Timed Text page',
},
{
group = 'defaultns=all',
args = {page = 'TimedText talk:Foo', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'defaultns=all',
args = {page = 'Special:PrefixIndex', defaultns = 'all'},
expected = 'special page',
},
{
group = 'defaultns=all',
args = {page = 'Media:Example.jpg', defaultns = 'all'},
expected = 'file',
},
{
group = 'custom namespace text',
args = {page = 'UK', redirect = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Talk:UK', redirect = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Talk:UK', talk = 'custom text'},
expected = 'redirect',
},
{
group = 'custom namespace text',
args = {page = 'United Kingdom', main = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Talk:United Kingdom', main = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Talk:United Kingdom', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'User:Example', user = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'User talk:Example', user = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'User talk:Example', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Wikipedia:Namespace', wikipedia = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Wikipedia talk:Namespace', wikipedia = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Wikipedia talk:Namespace', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Project:Namespace', project = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Project talk:Namespace', project = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Project talk:Namespace', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'WP:Namespace', wp = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'WT:Namespace', wp = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'WT:Namespace', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'WT:Namespace', wt = 'custom text'},
expected = 'page',
},
{
group = 'custom namespace text',
args = {page = 'Wikipedia:Namespace', project = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Wikipedia talk:Namespace', project = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'WP:Namespace', project = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'WT:Namespace', project = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Wikipedia:Namespace', wp = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Wikipedia talk:Namespace', wp = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Project:Namespace', wp = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Project talk:Namespace', wp = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'File:Example.jpg', file = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'File talk:Example.jpg', file = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'File talk:Example.jpg', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Image:Example.jpg', file = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Image talk:Example.jpg', file = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Image talk:Example.jpg', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'File:Example.jpg', image = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'File talk:Example.jpg', image = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'File talk:Example.jpg', image = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Image:Example.jpg', image = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Image talk:Example.jpg', image = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Image talk:Example.jpg', image = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'MediaWiki:Watchlist-details', mediawiki = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'MediaWiki talk:Watchlist-messages', mediawiki = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'MediaWiki talk:Watchlist-messages', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Template:Pagetype', template = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Template talk:Pagetype', template = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Template talk:Pagetype', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Help:Contents', help = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Help talk:Contents', help = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Help talk:Contents', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Category:Wikipedians', category = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Category talk:Wikipedians', category = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Category talk:Wikipedians', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Portal:The arts', portal = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Portal talk:The arts', portal = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Portal talk:The arts', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Draft:Example', draft = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Draft talk:Example', draft = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Draft talk:Example', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'TimedText:Foo', timedtext = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'TimedText talk:Foo', timedtext = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'TimedText talk:Foo', talk = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Special:PrefixIndex', special = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Media:Example.jpg', media = 'custom text'},
expected = 'custom text',
},
{
group = 'custom namespace text',
args = {page = 'Media:Example.jpg', file = 'custom text'},
expected = 'page',
},
--{args = {module = 'foo'}, expected = 'foo'}, -- This should be run on the talk page - it will not work if run in other places.
--{args = {talk = 'bar'}, expected = 'bar'}, -- This should be run on the talk page - it will not work if run in other places.
--{args = {module = 'foo', talk = 'bar'}, expected = 'bar'}, -- This should be run on the talk page - it will not work if run in other places.
{
group = 'order of precedence',
args = {page = 'Module:Pagetype/testcases', module = 'foo', talk = 'bar'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {page = 'UK', defaultns = 'none', redirect = 'foo'},
expected = 'foo'
},
{
group = 'order of precedence',
args = {page = 'UK', defaultns = 'none', redirect = 'foo', main = 'bar'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {page = 'UK', defaultns = 'extended', redirect = 'foo'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {page = 'UK', defaultns = 'extended', main = 'foo', redirect = 'bar'},
expected = 'bar',
},
{
group = 'order of precedence',
args = {page = 'UK', main = 'foo', redirect = 'bar'},
expected = 'bar',
},
{
group = 'order of precedence',
args = {'dab', page = 'UK', main = 'foo', redirect = 'bar', dab = 'baz'},
expected = 'bar',
},
{
group = 'order of precedence',
args = {'na', page = 'UK', main = 'foo', redirect = 'bar', na = 'baz'},
expected = 'bar',
},
{
group = 'order of precedence',
args = {page = 'Talk:UK', main = 'foo', redirect = 'bar'},
expected = 'bar',
}, -- Talk:UK is a redirect.
{
group = 'order of precedence',
args = {page = 'Talk:UK', main = 'foo', redirect = 'bar', talk = 'baz'},
expected = 'bar',
},
{
group = 'order of precedence',
args = {page = 'Foo', main = 'foo', redirect = 'bar'},
expected = 'bar',
}, -- Foo is a redirect.
{
group = 'order of precedence',
args = {page = 'Talk:Foo', main = 'foo', redirect = 'bar'},
expected = 'bar',
}, -- Talk:Foo is not a redirect.
{
group = 'order of precedence',
args = {page = 'Talk:Foo', main = 'foo', redirect = 'bar', talk = 'baz'},
expected = 'baz',
},
{
group = 'order of precedence',
args = {page = 'United Kingdom', main = 'foo', redirect = 'bar', talk = 'baz'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {'dab', page = 'United Kingdom', main = 'foo', redirect = 'bar', talk = 'baz'},
expected = 'page',
},
{
group = 'order of precedence',
args = {'dab', page = 'United Kingdom', main = 'foo', redirect = 'bar', talk = 'baz', dab = 'yes'},
expected = 'page',
},
{
group = 'order of precedence',
args = {'dab', page = 'United Kingdom', main = 'foo', redirect = 'bar', talk = 'baz', dab = 'bin'},
expected = 'bin',
},
{
group = 'order of precedence',
args = {'na', page = 'United Kingdom', main = 'foo', redirect = 'bar', talk = 'baz'},
expected = 'page',
},
{
group = 'order of precedence',
args = {'na', page = 'United Kingdom', main = 'foo', redirect = 'bar', talk = 'baz', na = 'yes'},
expected = 'page',
},
{
group = 'order of precedence',
args = {'na', page = 'United Kingdom', main = 'foo', redirect = 'bar', talk = 'baz', na = 'bin'},
expected = 'bin',
},
{
group = 'order of precedence',
args = {page = 'Wikipedia:Namespace', wp = 'foo', project = 'bar', wikipedia = 'baz'},
expected = 'baz',
},
{
group = 'order of precedence',
args = {page = 'Wikipedia:Namespace', wp = 'foo', project = 'bar'},
expected = 'bar',
},
{
group = 'order of precedence',
args = {page = 'Wikipedia:Namespace', wp = 'foo'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {page = 'Wikipedia:Namespace', wikipedia = 'foo', wp = 'bar'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {page = 'Wikipedia talk:Namespace', wp = 'foo', project = 'bar', wikipedia = 'baz'},
expected = 'baz',
},
{
group = 'order of precedence',
args = {page = 'Wikipedia talk:Namespace', wp = 'foo', project = 'bar', wikipedia = 'baz', talk = 'bin'},
expected = 'bin',
},
{
group = 'order of precedence',
args = {page = 'Project talk:Namespace', wp = 'foo', project = 'bar', wikipedia = 'baz'},
expected = 'baz',
},
{
group = 'order of precedence',
args = {page = 'Project talk:Namespace', wp = 'foo', project = 'bar', wikipedia = 'baz', talk = 'bin'},
expected = 'bin',
},
{
group = 'order of precedence',
args = {page = 'File:Example.jpg', file = 'foo', image = 'bar'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {page = 'File talk:Example.jpg', file = 'foo', image = 'bar'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {page = 'File talk:Example.jpg', file = 'foo', image = 'bar', talk = 'baz'},
expected = 'baz',
},
{
group = 'order of precedence',
args = {page = 'Image:Example.jpg', file = 'foo', image = 'bar'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {page = 'Image talk:Example.jpg', file = 'foo', image = 'bar'},
expected = 'foo',
},
{
group = 'order of precedence',
args = {page = 'Image talk:Example.jpg', file = 'foo', image = 'bar', talk = 'baz'},
expected = 'baz',
},
{
group = 'other parameters',
args = {page = 'Wikipedia:Namespace'},
expected = 'page',
},
{
group = 'other parameters',
args = {page = 'Wikipedia:Namespace', other = 'custom text'},
expected = 'custom text',
},
{
group = 'other parameters',
args = {page = 'Wikipedia:Namespace', other = 'no'},
expected = 'page',
},
{
group = 'other parameters',
args = {page = 'Wikipedia:Namespace', other = 'yes'},
expected = 'page',
},
{
group = 'other parameters',
args = {page = 'Wikipedia:Namespace', other = 'custom text', wikipedia = 'wikipedia-space text'},
expected = 'wikipedia-space text',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = 'yes'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = 'Yes'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = 'YeS'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = 'y'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = 'Y'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = 'true'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = 'True'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = 'TrUe'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = '1'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Wikipedia:Namespace', wikipedia = '1.0'},
expected = 'project page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = 'no'},
expected = 'page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = 'No'},
expected = 'page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = 'nO'},
expected = 'page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = 'n'},
expected = 'page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = 'N'},
expected = 'page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = 'false'},
expected = 'page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = 'False'},
expected = 'page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = 'fAlSe'},
expected = 'page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = '0'},
expected = 'page',
},
{
group = 'yesno',
args = {page = 'Template:Pagetype', template = '0.0'},
expected = 'page',
},
{
group = 'subject redirect defaultns=all',
args = {page = 'MediaWiki talk:Spam-blacklist/log', defaultns = 'all'},
expected = 'talk page',
},
{
group = 'caps',
args = {page = 'Wikipedia:Namespace', caps = 'y'},
expected = 'Page',
},
{
group = 'caps',
args = {page = 'Wikipedia:Namespace', caps = 'n'},
expected = 'page',
},
{
group = 'caps',
args = {page = 'Wikipedia:Namespace', caps = 'y', plural = 'y'},
expected = 'Pages'
},
}
for i, test in ipairs(tests) do
local invocation = mTemplateInvocation.invocation("pagetype", test.args)
local testName = string.format(
'test %03d (%s): %s produces "%s"',
i,
test.group,
invocation,
test.expected
)
suite[testName] = function (suite)
local actual = mMockTitle.patchTitleConstructors(mPageType.main, test.args)
suite:assertEquals(test.expected, actual)
end
end
return suite