Jump to content

Module:TwitterSnowflake/testcases: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
uh, will this work?
No edit summary
Line 4: Line 4:
function p:test_only_id() -- default date format is "Month Day, Year"
function p:test_only_id() -- default date format is "Month Day, Year"
self:preprocess_equals('{{#invoke:TwitterSnowflake | snowflakeToDate | id_str = 1345021162959503360}}', 'January 1, 2021')
self:preprocess_equals('{{#invoke:TwitterSnowflake | snowflakeToDate | id_str = 1345021162959503360}}', 'January 1, 2021')
end

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


Line 20: Line 16:
function p:test_weird_breaking_date() -- this one used to break old versions of the script, outputting "April 11, 2011"
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')
self:preprocess_equals('{{#invoke:TwitterSnowflake | snowflakeToDate | id_str = 574608900537761792}}', 'March 8, 2015')
end
--sandbox tests
function p:test_zzsandbox_only_id() -- default date format is "Month Day, Year"
self:preprocess_equals('{{#invoke:TwitterSnowflake/sandbox | snowflakeToDate | id_str = 1345021162959503360}}', 'January 1, 2021')
end
end


function p:test_zzsandbox_custom_output_format() -- tests date format "Day Month Year"
self:preprocess_equals('{{#invoke:TwitterSnowflake/sandbox | snowflakeToDate | id_str = 1345021162959503360 | format = %e %B %Y}}', ' 1 January 2021')
end

function p:test_zzsandbox_custom_epoch() -- uses Discord's epoch
self:preprocess_equals('{{#invoke:TwitterSnowflake/sandbox | snowflakeToDate | id_str = 797545051047460888 | epoch = 1420070400}}', 'January 9, 2021')
end

function p:test_zzsandbox_weird_breaking_date() -- this one used to break old versions of the script, outputting "April 11, 2011"
self:preprocess_equals('{{#invoke:TwitterSnowflake/sandbox | snowflakeToDate | id_str = 574608900537761792}}', 'March 8, 2015')
end
return p
return p

Revision as of 15:43, 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
--sandbox tests 
function p:test_zzsandbox_only_id() -- default date format is "Month Day, Year"
    self:preprocess_equals('{{#invoke:TwitterSnowflake/sandbox | snowflakeToDate | id_str = 1345021162959503360}}', 'January  1, 2021')
end

function p:test_zzsandbox_custom_output_format() -- tests date format "Day Month Year"
    self:preprocess_equals('{{#invoke:TwitterSnowflake/sandbox | snowflakeToDate | id_str = 1345021162959503360 | format = %e %B %Y}}', ' 1 January 2021')
end

function p:test_zzsandbox_custom_epoch() -- uses Discord's epoch
    self:preprocess_equals('{{#invoke:TwitterSnowflake/sandbox | snowflakeToDate | id_str = 797545051047460888 | epoch = 1420070400}}', 'January  9, 2021')
end

function p:test_zzsandbox_weird_breaking_date() -- this one used to break old versions of the script, outputting "April 11, 2011"
    self:preprocess_equals('{{#invoke:TwitterSnowflake/sandbox | snowflakeToDate | id_str = 574608900537761792}}', 'March  8, 2015')
end
return p