add collapsable TOC menu

This commit is contained in:
chrox
2014-10-14 21:33:13 +08:00
parent 46963df0bb
commit 7c9130744c
7 changed files with 282 additions and 29 deletions

View File

@@ -24,7 +24,7 @@ describe("Readertoc module", function()
local ticks_level_0 = nil
it("should get ticks of level 0", function()
ticks_level_0 = toc:getTocTicks(0)
DEBUG("ticks", ticks_level_0)
--DEBUG("ticks", ticks_level_0)
assert.are.same(28, #ticks_level_0)
end)
local ticks_level_1 = nil
@@ -68,4 +68,26 @@ describe("Readertoc module", function()
assert.are.same(0, toc:getChapterPagesDone(100, 0))
assert.are.same(10, toc:getChapterPagesDone(200, 0))
end)
describe("collasible TOC", function()
it("should collapse the secondary toc nodes by default", function()
toc:onShowToc()
assert.are.same(7, #toc.collapsed_toc)
end)
it("should not expand toc nodes that have no child nodes", function()
toc:expandToc(2)
assert.are.same(7, #toc.collapsed_toc)
end)
it("should expand toc nodes that have child nodes", function()
toc:expandToc(3)
assert.are.same(13, #toc.collapsed_toc)
toc:expandToc(18)
assert.are.same(18, #toc.collapsed_toc)
end)
it("should collapse toc nodes that have been expanded", function()
toc:collapseToc(3)
assert.are.same(12, #toc.collapsed_toc)
toc:collapseToc(18)
assert.are.same(7, #toc.collapsed_toc)
end)
end)
end)