summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-02-08 01:48:43 +0100
committerAki <please@ignore.pl>2024-02-08 01:48:43 +0100
commit89b7fc43530535ea0fb2114e5fa0cf5660ca37a0 (patch)
tree547bfb206159eea7b380e8fdc1db357c94b1bf57 /spec
parent85f53fed3026366c3970e26e2843be3d8e702c20 (diff)
downloadactivity-89b7fc43530535ea0fb2114e5fa0cf5660ca37a0.zip
activity-89b7fc43530535ea0fb2114e5fa0cf5660ca37a0.tar.gz
activity-89b7fc43530535ea0fb2114e5fa0cf5660ca37a0.tar.bz2
Fixed last two weeks of each year not showing up
Diffstat (limited to 'spec')
-rw-r--r--spec/activity_spec.lua26
-rw-r--r--spec/dates_spec.lua2
2 files changed, 24 insertions, 4 deletions
diff --git a/spec/activity_spec.lua b/spec/activity_spec.lua
index 634a228..197b57f 100644
--- a/spec/activity_spec.lua
+++ b/spec/activity_spec.lua
@@ -1,4 +1,5 @@
local activity = require "activity"
+local dates = require "activity.dates"
local plain = require "activity.formats.plain"
local Y2024 = [[
@@ -34,16 +35,35 @@ Fri 0000000000000000000000000000000000000000000000000000_
describe("Generator", function()
describe("shall generate correct table for year", function()
+ local function lookup (year, day) return 0 end
+
it("2024", function()
- assert.are.equal(Y2024, activity.generate_table(2024, {}, plain))
+ assert.are.equal(Y2024, activity.generate_table(2024, lookup, plain))
end)
it("2023", function()
- assert.are.equal(Y2023, activity.generate_table(2023, {}, plain))
+ assert.are.equal(Y2023, activity.generate_table(2023, lookup, plain))
end)
it("2020", function()
- assert.are.equal(Y2020, activity.generate_table(2020, {}, plain))
+ assert.are.equal(Y2020, activity.generate_table(2020, lookup, plain))
+ end)
+ end)
+
+ describe("shall put activity into cells for", function()
+ local function lookup (year, day)
+ if day < 1 or dates.days_in(year) < day then
+ return 0
+ end
+ return 1
+ end
+
+ it("regular years", function()
+ assert.are.equal(Y2023:gsub("0", "1"), activity.generate_table(2023, lookup, plain))
+ end)
+
+ it("leap years", function()
+ assert.are.equal(Y2024:gsub("0", "1"), activity.generate_table(2024, lookup, plain))
end)
end)
end)
diff --git a/spec/dates_spec.lua b/spec/dates_spec.lua
index b1d3594..a8b5a71 100644
--- a/spec/dates_spec.lua
+++ b/spec/dates_spec.lua
@@ -40,7 +40,7 @@ describe("First week day of", function()
assert.are.equal(7, dates.first_week_day(2022))
end)
- it("2020 is Saturday", function()
+ it("2020 is Wednesday", function()
assert.are.equal(4, dates.first_week_day(2020))
end)
end)