summaryrefslogtreecommitdiff
path: root/spec/activity_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/activity_spec.lua')
-rw-r--r--spec/activity_spec.lua26
1 files changed, 23 insertions, 3 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)