diff options
author | Aki <please@ignore.pl> | 2023-05-07 17:47:02 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-05-07 17:47:02 +0200 |
commit | 8ac1faa7950da39f8f10b110abdf7b10bdeaf66a (patch) | |
tree | 5397d8ffdc131e3e6aa09370cc5ca1319d6d4fb2 /spec | |
parent | f1ce49e5aece7c93392c5afadba0eed1bb59f5e4 (diff) | |
download | activity-8ac1faa7950da39f8f10b110abdf7b10bdeaf66a.zip activity-8ac1faa7950da39f8f10b110abdf7b10bdeaf66a.tar.gz activity-8ac1faa7950da39f8f10b110abdf7b10bdeaf66a.tar.bz2 |
Activity table is now generated by Lua script
Diffstat (limited to 'spec')
-rw-r--r-- | spec/activity_spec.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/activity_spec.lua b/spec/activity_spec.lua new file mode 100644 index 0000000..08160fa --- /dev/null +++ b/spec/activity_spec.lua @@ -0,0 +1,43 @@ +local activity = require "activity" + +describe("Days in a year", function() + it("should support regular years", function() + assert.are.equal(365, activity.days(1970)) + assert.are.equal(365, activity.days(2001)) + end) + + it("should support lean years", function() + assert.are.equal(366, activity.days(2004)) + assert.are.equal(366, activity.days(1980)) + end) + + it("should support *00 years", function() + assert.are.equal(366, activity.days(2000)) + assert.are.equal(365, activity.days(2100)) + assert.are.equal(365, activity.days(2200)) + assert.are.equal(365, activity.days(2300)) + assert.are.equal(366, activity.days(2400)) + end) +end) + +describe("This year is", function() + local this_year = os.date "%Y" -- Quite useless test + + it(tostring(this_year), function() + assert.are.equal(this_year, activity.this_year()) + end) +end) + +describe("First week day of", function() + it("2023 is Sunday", function() + assert.are.equal(1, activity.first_week_day(2023)) + end) + + it("2022 is Saturday", function() + assert.are.equal(7, activity.first_week_day(2022)) + end) + + it("2020 is Saturday", function() + assert.are.equal(4, activity.first_week_day(2020)) + end) +end) |