summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-02-10 01:37:25 +0100
committerAki <please@ignore.pl>2024-02-10 01:37:25 +0100
commitf68cc360d9800bdde6e0d639727d6812d81ead3a (patch)
tree83a4148f937f43779e171f24f40872360f59a4a5 /spec
parent0d372922aec1213fc90e48c835eeec2acc3aadb0 (diff)
downloadactivity-f68cc360d9800bdde6e0d639727d6812d81ead3a.zip
activity-f68cc360d9800bdde6e0d639727d6812d81ead3a.tar.gz
activity-f68cc360d9800bdde6e0d639727d6812d81ead3a.tar.bz2
Added some sanity tests that would have had helped but I didn't think of them
Diffstat (limited to 'spec')
-rw-r--r--spec/generators_spec.lua35
1 files changed, 32 insertions, 3 deletions
diff --git a/spec/generators_spec.lua b/spec/generators_spec.lua
index a6c1e9a..280aee3 100644
--- a/spec/generators_spec.lua
+++ b/spec/generators_spec.lua
@@ -81,18 +81,32 @@ describe("Yearly chart generator", function()
assert.are.equal(Y2024:gsub("0", "1"), generators.generate_table(2024, lookup, plain))
end)
end)
+
+ it("shall use entire format", function()
+ mock(plain)
+ _ = generators.generate_table(2023, always_zero, plain)
+ assert.spy(plain.start_document).was.called()
+ assert.spy(plain.start_table).was.called()
+ assert.spy(plain.start_row).was.called()
+ assert.spy(plain.label).was.called(7)
+ assert.spy(plain.spot).was.called(6)
+ assert.spy(plain.cell).was.called(365)
+ assert.spy(plain.end_row).was.called()
+ assert.spy(plain.end_table).was.called()
+ assert.spy(plain.end_document).was.called()
+ mock.revert(plain)
+ end)
end)
describe("Rolling chart generator", function()
+ local date = os.date("*t", os.time{year=2024, month=2, day=8})
+
it("shall generate empty table", function()
- local date = os.date("*t", os.time{year=2024, month=2, day=8})
assert.are.equal(ROLL, generators.generate_table("rolling", always_zero, plain, date))
end)
it("shall put activity into cells", function()
- local date = os.date("*t", os.time{year=2024, month=2, day=8})
-
local function lookup (year, day)
if year == 2023 and day >= 36 then
return 1
@@ -105,4 +119,19 @@ describe("Rolling chart generator", function()
assert.are.equal(ROLL:gsub("0", "1"), generators.generate_table("rolling", lookup, plain, date))
end)
+
+ it("shall use entire format", function()
+ mock(plain)
+ _ = generators.generate_table("rolling", always_zero, plain, date)
+ assert.spy(plain.start_document).was.called()
+ assert.spy(plain.start_table).was.called()
+ assert.spy(plain.start_row).was.called()
+ assert.spy(plain.label).was.called(7)
+ assert.spy(plain.spot).was.called(2)
+ assert.spy(plain.cell).was.called(369)
+ assert.spy(plain.end_row).was.called()
+ assert.spy(plain.end_table).was.called()
+ assert.spy(plain.end_document).was.called()
+ mock.revert(plain)
+ end)
end)