summaryrefslogtreecommitdiff
path: root/spec/generators_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/generators_spec.lua')
-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)