Module:Bad title suggestion/testcases

From MOASSpedia
< Module:Bad title suggestion
Revision as of 01:35, 27 February 2021 by Wikipedia>The Earwig (create)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Bad title suggestion/testcases/doc

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

function p:test_basic()
	self:preprocess_equals_preprocess('{{#invoke:Bad title suggestion|main|>|Foobar&#62;}}', '{{Did you mean box|Foobar}}')
end

function p:test_namespaced()
	self:preprocess_equals_preprocess('{{#invoke:Bad title suggestion|main|}|Wikipedia:Village pump&#125;&#125;}}', '{{Did you mean box|Wikipedia:Village pump}}')
end

function p:test_pipe()
	self:preprocess_equals_preprocess('{{#invoke:Bad title suggestion|main|||Main Page&#124;title text}}', '{{Did you mean box|Main Page}}')
end

function p:test_missing()
	self:preprocess_equals_preprocess('{{#invoke:Bad title suggestion|main|>|This page absolutely does not exist&#62;}}', '')
end

function p:test_category()
	self:preprocess_equals_preprocess('{{#invoke:Bad title suggestion|main|>|Category:Contents&#62;}}', '{{Did you mean box|Category:Contents}}')
end

function p:test_first_invalid()
	self:preprocess_equals_preprocess('{{#invoke:Bad title suggestion|main|<|&60;Foobar&#62;}}', '')
end

function p:test_empty()
	self:preprocess_equals_preprocess('{{#invoke:Bad title suggestion|main|>|}}', '')
end

return p