Jump to content

Module:TwitterSnowflake/testcases: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 19: Line 19:


function p:test_test() -- ugh, why is this broken
function p:test_test() -- ugh, why is this broken
self:preprocess_equals('{{#invoke:TwitterSnowflake | snowflakeToDate | id_str = 1345021162959503360 | format = %Y}}', '2021')
self:preprocess_equals('{{#invoke:TwitterSnowflake | snowflakeToDate | id_str = 1345021162959503360 | format = %e}}', '1')
end
end



Revision as of 15:32, 18 January 2021

-- Unit tests for [[Module:TwitterSnowflake]]. Click talk page to run tests. 
local p = require('Module:UnitTests')

function p:test_only_id() -- default date format is "Month Day, Year"
    self:preprocess_equals('{{#invoke:TwitterSnowflake | snowflakeToDate | id_str = 1345021162959503360}}', 'January 1, 2021')
end

function p:test_custom_output_format() -- tests date format "Day Month Year"
    self:preprocess_equals('{{#invoke:TwitterSnowflake | snowflakeToDate | 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 | snowflakeToDate | 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 | snowflakeToDate | id_str = 574608900537761792}}', 'March 8, 2015')
end

function p:test_test() -- ugh, why is this broken
    self:preprocess_equals('{{#invoke:TwitterSnowflake | snowflakeToDate | id_str = 1345021162959503360 | format = %e}}', '1')
end

return p