Module:Arguments/testcases

From blackwiki
< Module:Arguments
Revision as of 23:52, 9 December 2013 by blackwiki>Mr. Stradivarius (add some test structures)
Jump to navigation Jump to search

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

local getArgs = require('Module:Arguments').getArgs
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()

function suite.expandTestTemplate(funcName)
	local frame = mw.getCurrentFrame()
	local val = frame:preprocess('{{Module talk:Arguments/testTemplate|function=' .. funcName .. '}}')
	return val
end

function suite.createInvokeFunction(funcName, key, options)
	return function (frame)
		options = options or {}
		local args = getArgs(frame, options)
		return args[key]
	end
end

function suite.main(frame)
	local args = getArgs(frame)
	return args[1]
end

function suite.test()
	local frame = mw.getCurrentFrame()
	local mainVal = frame:preprocess('{{Module talk:Arguments/testInvoke|function=main}}')
	return mainVal
end

return suite