Jump to content

Module:Vital article/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Kammerer55 (talk | contribs) at 07:04, 9 December 2023. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Unit tests for [[Module:{{ROOTPAGENAME}}]]. Click talk page to run tests.
local p = require('Module:UnitTests')

local test_link_cases = {
	{ 'Philosophy',
		'[[Philosophy]] [[File:Círculos Concéntricos.svg|11px]] [[Wikipedia:Vital articles/Level/1#Level 1 vital articles (10 articles)|1]]'},
	{ 'philosophy',
		'[[philosophy]]'},
	{ 'Calamotropha punctivenellus',
		'[[Calamotropha punctivenellus]]'},
}

-- Example unit test.
function p:test_link()
	for page, link_value in test_link_cases do
		self:preprocess_equals('{{#invoke:Vital article|link|page=' .. page .. '}}', link_value)
	end
	self:preprocess_equals(
		'{{#invoke:Vital article|link|page=Philosophy}}',
		'[[Philosophy]] [[File:Círculos Concéntricos.svg|11px]] [[Wikipedia:Vital articles/Level/1#Level 1 vital articles (10 articles)|1]]')
	self:preprocess_equals(
		'{{#invoke:Vital article|link|page=philosophy}}',
		'[[philosophy]]')
	self:preprocess_equals(
		'{{#invoke:Vital article|link|page=Calamotropha punctivenellus}}',
		'[[Calamotropha punctivenellus]]')
end

function p:test_sandbox()
	self:preprocess_equals(
		'{{#invoke:Vital article|link|page=Philosophy}}',
		'{{#invoke:Vital article/sandbox|link|page=Philosophy}}')
	self:preprocess_equals(
		'{{#invoke:Vital article|link|page=philosophy}}',
		'{{#invoke:Vital article/sandbox|link|page=philosophy}}')
	self:preprocess_equals(
		'{{#invoke:Vital article|link|page=Calamotropha punctivenellus}}',
		'{{#invoke:Vital article/sandbox|link|page=Calamotropha punctivenellus}}')
end

return p