-- Unit tests for . Click talk page to run tests. local p = require('Module:UnitTests')
-- test snowflakeToDate
function p:test_snowflakeToDate_only_id -- default date format is "Month Day, Year" self:preprocess_equals('', 'January 1, 2021')end
function p:test_snowflakeToDate_custom_output_format -- tests date format "Day Month Year" self:preprocess_equals('', ' 1 January 2021')end
function p:test_snowflakeToDate_custom_epoch -- uses Discord's epoch self:preprocess_equals('', 'January 9, 2021')end
function p:test_snowflakeToDate_weird_breaking_date -- this one used to break old versions of the script, outputting "April 11, 2011" self:preprocess_equals('', 'March 8, 2015')end
-- test getDate
function p:test_getDate_date_off_by_five -- date off by five days, so this returns "5" self:preprocess_equals('', '5')end
function p:test_getDate_date_off_by_one -- date off by one day, so this returns "1" self:preprocess_equals('', '1')end
function p:test_getDate_date_match -- date matches, so this returns "0" self:preprocess_equals('', '0')end
function p:test_getDate_before_epoch -- posted before epoch, so this returns "-1" (date isn't correct here, but that's irrelevant — it can't check it either way) self:preprocess_equals('', '-1')end
function p:test_getDate_invalid_id_str -- id_str is invalid, so this returns "-2" self:preprocess_equals('', '-2')end
--sandbox tests for snowflakeToDate
function p:test_zzsandbox_snowflakeToDate_only_id -- default date format is "Month Day, Year" self:preprocess_equals('', 'January 1, 2021')end
function p:test_zzsandbox_snowflakeToDate_custom_output_format -- tests date format "Day Month Year" self:preprocess_equals('', ' 1 January 2021')end
function p:test_zzsandbox_snowflakeToDate_custom_epoch -- uses Discord's epoch self:preprocess_equals('', 'January 9, 2021')end
function p:test_zzsandbox_snowflakeToDate_weird_breaking_date -- this one used to break old versions of the script, outputting "April 11, 2011" self:preprocess_equals('', 'March 8, 2015')end
--sandbox tests for getDate
function p:test_zzsandbox_getDate_date_off_by_five -- date off by five days, so this returns "5" self:preprocess_equals('', '5')end
function p:test_zzsandbox_getDate_date_off_by_one -- date off by one day, so this returns "1" self:preprocess_equals('', '1')end
function p:test_zzsandbox_getDate_date_match -- date matches, so this returns "0" self:preprocess_equals('', '0')end
function p:test_zzsandbox_getDate_before_epoch -- posted before epoch, so this returns "-1" (date isn't correct here, but that's irrelevant — it can't check it either way) self:preprocess_equals('', '-1')end
function p:test_zzsandbox_getDate_invalid_id_str -- id_str is invalid, so this returns "-2" self:preprocess_equals('', '-2')end
return p