Allows easier testing of template-invokable functions that take a frame
object as the only argument.
-- Equivalent to {{grc-IPA|ἁγιότης}}
require "Module:frame test".test_frame_function(require "Module:grc-pronunciation".create, {}, { "ἁγιότης" })
local export = {}
local parent_frame = {}
-- parent_frame.args is set below.
local function get_parent_frame()
return parent_frame
end
-- frame_args: table; parent_frame_args: table; title: string (full pagename)
function export.test_frame_function(func, frame_args, parent_frame_args, title)
parent_frame.args = parent_frame_args
local frame = { args = frame_args, getParent = get_parent_frame }
if title then
-- Not always reliable and maybe dangerous.
mw.title.getCurrentTitle = function ()
return mw.title.new(title)
end
end
return func(frame)
end
return export