Module:ArgRest/testCaser
Appearance
This module is designed exclusively for providing an effective way to create testcases for Module:ArgRest, by "mocking" a transcluded template.
Usage
[edit]Simply wrap this template around ArgRest like so:
{{#invoke:ArgRest/testCaser|main|sourceCode=<nowiki>{{#invoke:ArgRest|<nowiki>...{{{1}}}...{{{2}}}...</nowiki>|[name of a parameter]}}|(other parameters)}}
and then attach arguments to "feed" to ArgRest at the end.
p = {}
function p.main(frame)
local code = frame.args['sourceCode'] or error("sourceCode arg not provided")
if code:match'nowiki' then -- undo nowiki sanitization
code = mw.text.unstripNoWiki(code)
else error("sourceCode arg was missing <nowiki>") end
return frame:preprocess(code:gsub("<", "<"):gsub(">", ">"))
end
return p