Module:TwitterSnowflake/testcases
Appearance
![]() | This is the test cases page for the module Module:TwitterSnowflake. Results of the test cases. |
-- Unit tests for [[Module:TwitterSnowflake]]. Click talk page to run tests.
local p = require('Module:TwitterSnowflake')
function p:test_only_id() -- default date format is "Month Day, Year"
self:preprocess_equals('{{#invoke:TwitterSnowflake | id_str = 1345021162959503360}}', 'January 1, 2021')
end
function p:test_custom_output_format() -- tests date format "Day Month Year"
self:preprocess_equals('{{#invoke:TwitterSnowflake | id_str = 1345021162959503360 | format = %e %B %Y}}', '1 January 2021')
end
function p:test_custom_epoch() -- uses Discord's epoch
self:preprocess_equals('{{#invoke:TwitterSnowflake | id_str = 797545051047460888 | epoch = 1420070400}}', 'January 9, 2021')
end
function p:test_weird_breaking_date() -- this one used to break old versions of the script, outputting "April 11, 2011"
self:preprocess_equals('{{#invoke:TwitterSnowflake | id_str = 574608900537761792}}', 'March 8, 2015')
end
return p