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.lua40
1 files changed, 32 insertions, 8 deletions
diff --git a/spec/activity_spec.lua b/spec/activity_spec.lua
index 581b0ba..38338e8 100644
--- a/spec/activity_spec.lua
+++ b/spec/activity_spec.lua
@@ -43,21 +43,26 @@ Fri 0000000000000000000000000000000000000000000000000000_
]]
-describe("Generator", function()
- describe("shall generate correct table for year", function()
- local function lookup (year, day) return 0 end
+local
+function always_zero (...)
+ return 0
+end
+
+describe("Yearly chart generator", function()
+ describe("shall generate empty table for year", function()
it("2024", function()
- assert.are.equal(Y2024, activity.generate_table(2024, lookup, plain))
+ assert.are.equal(Y2024, activity.generate_table(2024, always_zero, plain))
end)
it("2023", function()
- assert.are.equal(Y2023, activity.generate_table(2023, lookup, plain))
+ assert.are.equal(Y2023, activity.generate_table(2023, always_zero, plain))
end)
it("2020", function()
- assert.are.equal(Y2020, activity.generate_table(2020, lookup, plain))
+ assert.are.equal(Y2020, activity.generate_table(2020, always_zero, plain))
end)
+
end)
describe("shall put activity into cells for", function()
@@ -76,9 +81,28 @@ describe("Generator", function()
assert.are.equal(Y2024:gsub("0", "1"), activity.generate_table(2024, lookup, plain))
end)
end)
+end)
+
+
+describe("Rolling chart generator", function()
+ it("shall generate empty table", function()
+ local date = os.date("*t", os.time{year=2024, month=2, day=8})
+ assert.are.equal(ROLL, activity.generate_table("rolling", always_zero, plain, date))
+ end)
- it("shall support generating rolling table", function()
+ it("shall put activity into cells", function()
local date = os.date("*t", os.time{year=2024, month=2, day=8})
- assert.are.equal(ROLL, activity.generate_table("rolling", lookup, plain, date))
+
+ local function lookup (year, day)
+ if year == 2023 and day >= 36 then
+ return 1
+ end
+ if year == 2024 and day <= 39 then
+ return 1
+ end
+ return 0
+ end
+
+ assert.are.equal(ROLL:gsub("0", "1"), activity.generate_table("rolling", lookup, plain, date))
end)
end)