Module:Navbar/testcases

From Bonkipedia
< Module:Navbar
Revision as of 18:20, 12 November 2022 by ManfredoDo (talk | contribs) (1 revision imported: Module Import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Production


h

V/doc






Sandbox


h

V/doc







-- Quick and few tests of using the _navbar function directly,
-- as they won't be caught in tests of {{navbar}}

-- TODO: Convert to use [[Module:ScribuntoUnit]]

local p = {}
require('strict') --make sure no globals

function p.run(frame)
	local toRun;
	if (type(frame) == 'table') then
		if (type(frame.args) == 'table'
			and type(frame.getParent) == 'function') then
			toRun = frame.args.module
		else
			toRun = frame.module
		end
	end

	local n = require(toRun and (
			-- The "Module:" namespace prefix is case insensitive and can
			-- be preceded with a single colon
			mw.ustring.match(toRun, "^:?[Mm][Oo][Dd][Uu][Ll][Ee]:")
			and toRun or 'Module:' .. toRun)
		or 'Module:Navbar')

	local out = {}
	for i = 1,2 do
		local k = {'yes', nil}
		table.insert(out, {
			n._navbar({collapsible = k[i], template =  'V/doc'}),
			'<hr style="clear:both"/>',
			n._navbar({collapsible = k[i], template = 'V/doc', 'h', 'm', ''}),
			'<hr style="clear:both"/>',
			n._navbar({collapsible = k[i], 'V/doc', 'h', 'm'}),
			'<hr style="clear:both"/><hr style="clear:both"/>'
		})
	end

	table.insert(out, { n._navbar{mini = 'yes', 'v/doc'} })
	return table.concat(out[1])..table.concat(out[2])..table.concat(out[3])
end
return p