local p = require('Module:UnitTests')
function p:test_timeAgotest_main()
local lang = mw.language.getContentLanguage()
yearsuntilaug57 = math.floor( ( lang:formatDate ( 'U', '4 August 2057' ) - currentTime ) / 31557600 )
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|15 September 2013}}', monthssincesep13 .. ' months ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|{{CURRENTTIMESTAMP}}}}', '0 seconds ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|15 September 2013|purge=yes}}', monthssincesep13 .. ' months ago <span class="plainlinks">([//en.wikipedia.org/w/index.php?title=Module_talk:TimeAgo/testcases&action=purge purge])</span>')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|{{CURRENTTIMESTAMP}}|purge=yes}}', '0 seconds ago <span class="plainlinks">([//en.wikipedia.org/w/index.php?title=Module_talk:TimeAgo/testcases&action=purge purge])</span>')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|July 1 2009}}', yearssincejul09 .. ' years ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|July 1 2009|magnitude=minutes}}', minutessincejul09 .. ' minutes ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|July 1 2009|magnitude=days}}', dayssincejul09 .. ' days ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|July 1 2009|magnitude=weeks}}', weekssincejul09 .. ' weeks ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|July 1 2009|magnitude=months}}', monthssincejul09 .. ' months ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|July 1 2049|magnitude=months}}', monthsuntiljul49 .. ' months\' time')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|Julio 1}}', '<strong class="error">Error: first parameter cannot be parsed as a date or time.</strong>')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|July 1 2009|magnitude=fruits}}', secondssincejul09 .. ' seconds ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain}}', '0 seconds ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|July 1 2009|magnitude=HoUrS}}', secondssincejul09 .. ' seconds ago')
self:preprocess_equals('{{#invoke:TimeAgo|timeAgomain|4 August 2057}}', yearsuntilaug57 .. ' years\' time')
end
|