Difference between revisions of "Module:Pagetype/testcases"

From blackwiki
Jump to navigation Jump to search
blackwiki>Mr. Stradivarius
(add some test cases)
 
blackwiki>Mr. Stradivarius
(fix a couple of mistakes)
Line 41: Line 41:
 
{'|page=Template:Pagetype', 'template'},
 
{'|page=Template:Pagetype', 'template'},
 
{'|page=Template talk:Pagetype', 'template'},
 
{'|page=Template talk:Pagetype', 'template'},
{'|page=Help:Index', 'page'},
+
{'|page=Help:Contents', 'page'},
{'|page=Help talk:Index', 'page'},
+
{'|page=Help talk:Contents', 'page'},
 
{'|page=Category:Wikipedians', 'category'},
 
{'|page=Category:Wikipedians', 'category'},
 
{'|page=Category talk:Wikipedians', 'category'},
 
{'|page=Category talk:Wikipedians', 'category'},
 
{'|page=Portal:Arts', 'page'},
 
{'|page=Portal:Arts', 'page'},
{'|page=Portal talk', 'page'},
+
{'|page=Portal talk:Arts', 'page'},
 
{'|page=Book:Countries', 'book'},
 
{'|page=Book:Countries', 'book'},
 
{'|page=Book talk:Countries', 'book'},
 
{'|page=Book talk:Countries', 'book'},

Revision as of 07:25, 27 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

return p