local mItalicTitle = require('Module:Italic title/sandbox')local ScribuntoUnit = require('Module:ScribuntoUnit')local Spy = require('Module:Lua-mock/Spy')local suite = ScribuntoUnit:new
local function patchCurrentTitle(page, func) local oldGetCurrentTitle = mw.title.getCurrentTitle mw.title.getCurrentTitle = function return mw.title.new(page) end func mw.title.getCurrentTitle = oldGetCurrentTitleend
local function patchDisplayTitle(func) local oldGetCurrentFrame = mw.getCurrentFrame local frame = oldGetCurrentFrame local oldCallParserFunction = frame.callParserFunction local callParserFunctionSpy = Spy(oldCallParserFunction) mw.getCurrentFrame = function return frame end frame.callParserFunction = callParserFunctionSpy func(callParserFunctionSpy, frame) frame.callParserFunction = oldCallParserFunction mw.getCurrentFrame = oldGetCurrentFrameend
local displayTitleTestData =
for _, testData in ipairs(displayTitleTestData) do suite[testData.description] = function (self) patchCurrentTitle(testData.page, function patchDisplayTitle(function (callParserFunctionSpy, frame) testData.func(testData.args) callParserFunctionSpy:assertCallMatches end ) end ) endend
local categoryTestData =
for _, testData in ipairs(categoryTestData) do suite[testData.description] = function (self) patchCurrentTitle(testData.page, function self:assertStringContains(testData.func(testData.args), "", true ) end ) endend
return suite