Module:Current events monthly archive/testcases/sandbox explained

-- Unit tests for .-- View to run tests.-- While editing, preview this against

-- We are just going to test the date info, and assume that all our argument--- checking code is correct, so make that clear here.local getDateInfo = require('Module:Current events monthly archive/sandbox').getDateInfolocal suite = require('Module:ScribuntoUnit'):new

-- Test datalocal testData =

for _, dateData in ipairs(testData) do local year = dateData.date.year local month = dateData.date.month for field, value in pairs(dateData.results) do local funcName = string.format('test_%04d_%02d_%s', year, month, field ) suite[funcName] = function (self) -- We could have got the date info once for each date, -- but doing it once for each field ensures that our -- tests don't depend on any state changes made by -- previous tests. This makes the tests less efficient, -- but probably not enough to make much actual -- difference. local dateInfo = getDateInfo(year, month) self:assertEquals(value, dateInfo[field]) end endend

return suite