Difference between revisions of "Module:Pagetype/testcases"

From blackwiki
Jump to navigation Jump to search
blackwiki>Mr. Stradivarius
(add custom namespace test cases)
blackwiki>Mr. Stradivarius
(fixes)
Line 179: Line 179:
 
{'|page=UK|redirect=custom text', 'custom text'},
 
{'|page=UK|redirect=custom text', 'custom text'},
 
{'|page=Talk:UK|redirect=custom text', 'custom text'},
 
{'|page=Talk:UK|redirect=custom text', 'custom text'},
{'|page=Talk:UK|talk=custom text', 'custom text'},
+
{'|page=Talk:UK|talk=custom text', 'redirect'},
{'|page=United Kingdom|article=custom text', 'custom text'},
+
{'|page=United Kingdom|main=custom text', 'custom text'},
{'|page=Talk:United Kingdom|article=custom text', 'custom text'},
+
{'|page=Talk:United Kingdom|main=custom text', 'custom text'},
 
{'|page=Talk:United Kingdom|talk=custom text', 'custom text'},
 
{'|page=Talk:United Kingdom|talk=custom text', 'custom text'},
 
{'|page=User:Example|user=custom text', 'custom text'},
 
{'|page=User:Example|user=custom text', 'custom text'},
Line 204: Line 204:
 
{'|page=Project:Namespace|wp=custom text', 'custom text'},
 
{'|page=Project:Namespace|wp=custom text', 'custom text'},
 
{'|page=Project talk:Namespace|wp=custom text', 'custom text'},
 
{'|page=Project talk:Namespace|wp=custom text', 'custom text'},
{'|page=File:Example.svg|file=custom text', 'custom text'},
+
{'|page=File:Example.jpg|file=custom text', 'custom text'},
{'|page=File talk:Example.svg|file=custom text', 'custom text'},
+
{'|page=File talk:Example.jpg|file=custom text', 'custom text'},
{'|page=File talk:Example.svg|talk=custom text', 'custom text'},
+
{'|page=File talk:Example.jpg|talk=custom text', 'custom text'},
{'|page=Image:Example.svg|file=custom text', 'custom text'},
+
{'|page=Image:Example.jpg|file=custom text', 'custom text'},
{'|page=Image talk:Example.svg|file=custom text', 'custom text'},
+
{'|page=Image talk:Example.jpg|file=custom text', 'custom text'},
{'|page=Image talk:Example.svg|talk=custom text', 'custom text'},
+
{'|page=Image talk:Example.jpg|talk=custom text', 'custom text'},
{'|page=File:Example.svg|image=custom text', 'custom text'},
+
{'|page=File:Example.jpg|image=custom text', 'custom text'},
{'|page=File talk:Example.svg|image=custom text', 'custom text'},
+
{'|page=File talk:Example.jpg|image=custom text', 'custom text'},
{'|page=File talk:Example.svg|image=custom text', 'custom text'},
+
{'|page=File talk:Example.jpg|image=custom text', 'custom text'},
{'|page=Image:Example.svg|image=custom text', 'custom text'},
+
{'|page=Image:Example.jpg|image=custom text', 'custom text'},
{'|page=Image talk:Example.svg|image=custom text', 'custom text'},
+
{'|page=Image talk:Example.jpg|image=custom text', 'custom text'},
{'|page=Image talk:Example.svg|image=custom text', 'custom text'},
+
{'|page=Image talk:Example.jpg|image=custom text', 'custom text'},
 
{'|page=MediaWiki:Watchlist-details|mediawiki=custom text', 'custom text'},
 
{'|page=MediaWiki:Watchlist-details|mediawiki=custom text', 'custom text'},
 
{'|page=MediaWiki talk:Watchlist-details|mediawiki=custom text', 'custom text'},
 
{'|page=MediaWiki talk:Watchlist-details|mediawiki=custom text', 'custom text'},

Revision as of 07:08, 28 October 2013

Documentation for this module may be created at Module:Pagetype/testcases/doc

-- Unit tests for [[Module:Pagetype]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_current_page()
	self:preprocess_equals_many('{{#invoke:pagetype|main', '}}', {
		{'', 'module'},
		{'|module=no', 'page'},
		{'|module=foo', 'foo'},
	})
end

function p:test_spaces()
	self:preprocess_equals_many('{{#invoke:pagetype|main', '}}', {
		{'', 'module'},
		{'|module=  no  ', 'page'},
		{'|module=  foo  ', 'foo'},
		{'|page=  UK  |redirect=  No  ', 'article'},
	})
end

function p:test_all_namespaces()
	self:preprocess_equals_many('{{#invoke:pagetype|main', '}}', {
		{'|page=UK', 'redirect'},
		{'|page=Talk:UK', 'redirect'},
		{'|page=United Kingdom', 'article'},
		{'|page=Talk:United Kingdom', 'article'},
		{'|page=User:Example', 'page'},
		{'|page=User talk:Example', 'page'},
		{'|page=Wikipedia:Namespace', 'page'},
		{'|page=Wikipedia talk:Namespace', 'page'},
		{'|page=Project:Namespace', 'page'},
		{'|page=Project talk:Namespace', 'page'},
		{'|page=WP:Namespace', 'page'},
		{'|page=WT:Namespace', 'page'},
		{'|page=File:Example.svg', 'file'},
		{'|page=File talk:Example.svg', 'file'},
		{'|page=Image:Example.svg', 'file'},
		{'|page=Image talk:Example.svg', 'file'},
		{'|page=MediaWiki:Watchlist-details', 'page'},
		{'|page=MediaWiki talk:Watchlist-details', 'page'},
		{'|page=Template:Pagetype', 'template'},
		{'|page=Template talk:Pagetype', 'template'},
		{'|page=Help:Contents', 'page'},
		{'|page=Help talk:Contents', 'page'},
		{'|page=Category:Wikipedians', 'category'},
		{'|page=Category talk:Wikipedians', 'category'},
		{'|page=Portal:Arts', 'page'},
		{'|page=Portal talk:Arts', 'page'},
		{'|page=Book:Countries', 'book'},
		{'|page=Book talk:Countries', 'book'},
		{'|page=Education Program:Foo', 'page'},
		{'|page=Education Program talk:Foo', 'page'},
		{'|page=TimedText:Foo', 'page'},
		{'|page=TimedText talk:Foo', 'page'},
		{'|page=Special:PrefixIndex', 'page'},
		{'|page=Media:Example.svg', 'page'},
	})
end

function p:test_defaultns_none()
	self:preprocess_equals_many('{{#invoke:pagetype|main', '}}', {
		{'|page=UK|defaultns=none', 'redirect'},
		{'|page=Talk:UK|defaultns=none', 'redirect'},
		{'|page=United Kingdom|defaultns=none', 'page'},
		{'|page=Talk:United Kingdom|defaultns=none', 'page'},
		{'|page=User:Example|defaultns=none', 'page'},
		{'|page=User talk:Example|defaultns=none', 'page'},
		{'|page=Wikipedia:Namespace|defaultns=none', 'page'},
		{'|page=Wikipedia talk:Namespace|defaultns=none', 'page'},
		{'|page=Project:Namespace|defaultns=none', 'page'},
		{'|page=Project talk:Namespace|defaultns=none', 'page'},
		{'|page=WP:Namespace|defaultns=none', 'page'},
		{'|page=WT:Namespace|defaultns=none', 'page'},
		{'|page=File:Example.svg|defaultns=none', 'page'},
		{'|page=File talk:Example.svg|defaultns=none', 'page'},
		{'|page=Image:Example.svg|defaultns=none', 'page'},
		{'|page=Image talk:Example.svg|defaultns=none', 'page'},
		{'|page=MediaWiki:Watchlist-details|defaultns=none', 'page'},
		{'|page=MediaWiki talk:Watchlist-details|defaultns=none', 'page'},
		{'|page=Template:Pagetype|defaultns=none', 'page'},
		{'|page=Template talk:Pagetype|defaultns=none', 'page'},
		{'|page=Help:Contents|defaultns=none', 'page'},
		{'|page=Help talk:Contents|defaultns=none', 'page'},
		{'|page=Category:Wikipedians|defaultns=none', 'page'},
		{'|page=Category talk:Wikipedians|defaultns=none', 'page'},
		{'|page=Portal:Arts|defaultns=none', 'page'},
		{'|page=Portal talk:Arts|defaultns=none', 'page'},
		{'|page=Book:Countries|defaultns=none', 'page'},
		{'|page=Book talk:Countries|defaultns=none', 'page'},
		{'|page=Education Program:Foo|defaultns=none', 'page'},
		{'|page=Education Program talk:Foo|defaultns=none', 'page'},
		{'|page=TimedText:Foo|defaultns=none', 'page'},
		{'|page=TimedText talk:Foo|defaultns=none', 'page'},
		{'|page=Special:PrefixIndex|defaultns=none', 'page'},
		{'|page=Media:Example.svg|defaultns=none', 'page'},
	})
end

function p:test_defaultns_extended()
	self:preprocess_equals_many('{{#invoke:pagetype|main', '}}', {
		{'|page=UK|defaultns=extended', 'redirect'},
		{'|page=Talk:UK|defaultns=extended', 'redirect'},
		{'|page=United Kingdom|defaultns=extended', 'article'},
		{'|page=Talk:United Kingdom|defaultns=extended', 'article'},
		{'|page=User:Example|defaultns=extended', 'user page'},
		{'|page=User talk:Example|defaultns=extended', 'user page'},
		{'|page=Wikipedia:Namespace|defaultns=extended', 'project page'},
		{'|page=Wikipedia talk:Namespace|defaultns=extended', 'project page'},
		{'|page=Project:Namespace|defaultns=extended', 'project page'},
		{'|page=Project talk:Namespace|defaultns=extended', 'project page'},
		{'|page=WP:Namespace|defaultns=extended', 'project page'},
		{'|page=WT:Namespace|defaultns=extended', 'project page'},
		{'|page=File:Example.svg|defaultns=extended', 'file'},
		{'|page=File talk:Example.svg|defaultns=extended', 'file'},
		{'|page=Image:Example.svg|defaultns=extended', 'file'},
		{'|page=Image talk:Example.svg|defaultns=extended', 'file'},
		{'|page=MediaWiki:Watchlist-details|defaultns=extended', 'interface page'},
		{'|page=MediaWiki talk:Watchlist-details|defaultns=extended', 'interface page'},
		{'|page=Template:Pagetype|defaultns=extended', 'template'},
		{'|page=Template talk:Pagetype|defaultns=extended', 'template'},
		{'|page=Help:Contents|defaultns=extended', 'help page'},
		{'|page=Help talk:Contents|defaultns=extended', 'help page'},
		{'|page=Category:Wikipedians|defaultns=extended', 'category'},
		{'|page=Category talk:Wikipedians|defaultns=extended', 'category'},
		{'|page=Portal:Arts|defaultns=extended', 'portal'},
		{'|page=Portal talk:Arts|defaultns=extended', 'portal'},
		{'|page=Book:Countries|defaultns=extended', 'book'},
		{'|page=Book talk:Countries|defaultns=extended', 'book'},
		{'|page=Education Program:Foo|defaultns=extended', 'page'},
		{'|page=Education Program talk:Foo|defaultns=extended', 'page'},
		{'|page=TimedText:Foo|defaultns=extended', 'page'},
		{'|page=TimedText talk:Foo|defaultns=extended', 'page'},
		{'|page=Special:PrefixIndex|defaultns=extended', 'page'},
		{'|page=Media:Example.svg|defaultns=extended', 'page'},
	})
end

function p:test_defaultns_all()
	self:preprocess_equals_many('{{#invoke:pagetype|main', '}}', {
		{'|page=UK|defaultns=all', 'redirect'},
		{'|page=Talk:UK|defaultns=all', 'redirect'},
		{'|page=United Kingdom|defaultns=all', 'article'},
		{'|page=Talk:United Kingdom|defaultns=all', 'talk page'},
		{'|page=User:Example|defaultns=all', 'user page'},
		{'|page=User talk:Example|defaultns=all', 'talk page'},
		{'|page=Wikipedia:Namespace|defaultns=all', 'project page'},
		{'|page=Wikipedia talk:Namespace|defaultns=all', 'talk page'},
		{'|page=Project:Namespace|defaultns=all', 'project page'},
		{'|page=Project talk:Namespace|defaultns=all', 'talk page'},
		{'|page=WP:Namespace|defaultns=all', 'project page'},
		{'|page=WT:Namespace|defaultns=all', 'talk page'},
		{'|page=File:Example.svg|defaultns=all', 'file'},
		{'|page=File talk:Example.svg|defaultns=all', 'talk page'},
		{'|page=Image:Example.svg|defaultns=all', 'file'},
		{'|page=Image talk:Example.svg|defaultns=all', 'talk page'},
		{'|page=MediaWiki:Watchlist-details|defaultns=all', 'interface page'},
		{'|page=MediaWiki talk:Watchlist-details|defaultns=all', 'talk page'},
		{'|page=Template:Pagetype|defaultns=all', 'template'},
		{'|page=Template talk:Pagetype|defaultns=all', 'talk page'},
		{'|page=Help:Contents|defaultns=all', 'help page'},
		{'|page=Help talk:Contents|defaultns=all', 'talk page'},
		{'|page=Category:Wikipedians|defaultns=all', 'category'},
		{'|page=Category talk:Wikipedians|defaultns=all', 'talk page'},
		{'|page=Portal:Arts|defaultns=all', 'portal'},
		{'|page=Portal talk:Arts|defaultns=all', 'talk page'},
		{'|page=Book:Countries|defaultns=all', 'book'},
		{'|page=Book talk:Countries|defaultns=all', 'talk page'},
		{'|page=Education Program:Foo|defaultns=all', 'education program page'},
		{'|page=Education Program talk:Foo|defaultns=all', 'talk page'},
		{'|page=TimedText:Foo|defaultns=all', 'Timed Text page'},
		{'|page=TimedText talk:Foo|defaultns=all', 'talk page'},
		{'|page=Special:PrefixIndex|defaultns=all', 'special page'},
		{'|page=Media:Example.svg|defaultns=all', 'file'},
	})
end

function p:test_custom_namespace_text()
	self:preprocess_equals_many('{{#invoke:pagetype|main', '}}', {
		{'|page=UK|redirect=custom text', 'custom text'},
		{'|page=Talk:UK|redirect=custom text', 'custom text'},
		{'|page=Talk:UK|talk=custom text', 'redirect'},
		{'|page=United Kingdom|main=custom text', 'custom text'},
		{'|page=Talk:United Kingdom|main=custom text', 'custom text'},
		{'|page=Talk:United Kingdom|talk=custom text', 'custom text'},
		{'|page=User:Example|user=custom text', 'custom text'},
		{'|page=User talk:Example|user=custom text', 'custom text'},
		{'|page=User talk:Example|talk=custom text', 'custom text'},
		{'|page=Wikipedia:Namespace|wikipedia=custom text', 'custom text'},
		{'|page=Wikipedia talk:Namespace|wikipedia=custom text', 'custom text'},
		{'|page=Wikipedia talk:Namespace|talk=custom text', 'custom text'},
		{'|page=Project:Namespace|project=custom text', 'custom text'},
		{'|page=Project talk:Namespace|project=custom text', 'custom text'},
		{'|page=Project talk:Namespace|talk=custom text', 'custom text'},
		{'|page=WP:Namespace|wp=custom text', 'custom text'},
		{'|page=WT:Namespace|wp=custom text', 'custom text'},
		{'|page=WT:Namespace|talk=custom text', 'custom text'},
		{'|page=WT:Namespace|wt=custom text', 'page'},
		{'|page=Wikipedia:Namespace|project=custom text', 'custom text'},
		{'|page=Wikipedia talk:Namespace|project=custom text', 'custom text'},
		{'|page=WP:Namespace|project=custom text', 'custom text'},
		{'|page=WT:Namespace|project=custom text', 'custom text'},
		{'|page=Wikipedia:Namespace|wp=custom text', 'custom text'},
		{'|page=Wikipedia talk:Namespace|wp=custom text', 'custom text'},
		{'|page=Project:Namespace|wp=custom text', 'custom text'},
		{'|page=Project talk:Namespace|wp=custom text', 'custom text'},
		{'|page=File:Example.jpg|file=custom text', 'custom text'},
		{'|page=File talk:Example.jpg|file=custom text', 'custom text'},
		{'|page=File talk:Example.jpg|talk=custom text', 'custom text'},
		{'|page=Image:Example.jpg|file=custom text', 'custom text'},
		{'|page=Image talk:Example.jpg|file=custom text', 'custom text'},
		{'|page=Image talk:Example.jpg|talk=custom text', 'custom text'},
		{'|page=File:Example.jpg|image=custom text', 'custom text'},
		{'|page=File talk:Example.jpg|image=custom text', 'custom text'},
		{'|page=File talk:Example.jpg|image=custom text', 'custom text'},
		{'|page=Image:Example.jpg|image=custom text', 'custom text'},
		{'|page=Image talk:Example.jpg|image=custom text', 'custom text'},
		{'|page=Image talk:Example.jpg|image=custom text', 'custom text'},
		{'|page=MediaWiki:Watchlist-details|mediawiki=custom text', 'custom text'},
		{'|page=MediaWiki talk:Watchlist-details|mediawiki=custom text', 'custom text'},
		{'|page=MediaWiki talk:Watchlist-details|talk=custom text', 'custom text'},
		{'|page=Template:Pagetype|template=custom text', 'custom text'},
		{'|page=Template talk:Pagetype|template=custom text', 'custom text'},
		{'|page=Template talk:Pagetype|talk=custom text', 'custom text'},
		{'|page=Help:Contents|help=custom text', 'custom text'},
		{'|page=Help talk:Contents|help=custom text', 'custom text'},
		{'|page=Help talk:Contents|talk=custom text', 'custom text'},
		{'|page=Category:Wikipedians|category=custom text', 'custom text'},
		{'|page=Category talk:Wikipedians|category=custom text', 'custom text'},
		{'|page=Category talk:Wikipedians|talk=custom text', 'custom text'},
		{'|page=Portal:Arts|portal=custom text', 'custom text'},
		{'|page=Portal talk:Arts|portal=custom text', 'custom text'},
		{'|page=Portal talk:Arts|talk=custom text', 'custom text'},
		{'|page=Book:Countries|book=custom text', 'custom text'},
		{'|page=Book talk:Countries|book=custom text', 'custom text'},
		{'|page=Book talk:Countries|talk=custom text', 'custom text'},
		{'|page=Education Program:Foo|education program=custom text', 'custom text'},
		{'|page=Education Program talk:Foo|education program=custom text', 'custom text'},
		{'|page=Education Program talk:Foo|talk=custom text', 'custom text'},
		{'|page=TimedText:Foo|timedtext=custom text', 'custom text'},
		{'|page=TimedText talk:Foo|timedtext=custom text', 'custom text'},
		{'|page=TimedText talk:Foo|talk=custom text', 'custom text'},
		{'|page=Special:PrefixIndex|special=custom text', 'custom text'},
		{'|page=Media:Example.svg|media=custom text', 'custom text'},
		{'|page=Media:Example.svg|file=custom text', 'page'},
	})
end

return p