|
|
|
@ -15,9 +15,10 @@ describe("Readertoc module", function()
|
|
|
|
|
assert.are.same(2, toc_max_depth)
|
|
|
|
|
end)
|
|
|
|
|
it("should get toc title from page", function()
|
|
|
|
|
local title = toc:getTocTitleByPage(56)
|
|
|
|
|
local title = toc:getTocTitleByPage(54)
|
|
|
|
|
--DEBUG("toc", toc.toc)
|
|
|
|
|
assert(title == "Prologue")
|
|
|
|
|
local title = toc:getTocTitleByPage(172)
|
|
|
|
|
local title = toc:getTocTitleByPage(162)
|
|
|
|
|
assert(title == "SCENE IV. Hall in Capulet's house.")
|
|
|
|
|
end)
|
|
|
|
|
describe("getTocTicks API", function()
|
|
|
|
@ -49,24 +50,24 @@ describe("Readertoc module", function()
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
it("should get page of next chapter", function()
|
|
|
|
|
assert.are.same(25, toc:getNextChapter(10, 0))
|
|
|
|
|
assert.are.same(103, toc:getNextChapter(100, 0))
|
|
|
|
|
assert.are.same(23, toc:getNextChapter(10, 0))
|
|
|
|
|
assert.are.same(112, toc:getNextChapter(100, 0))
|
|
|
|
|
assert.are.same(nil, toc:getNextChapter(200, 0))
|
|
|
|
|
end)
|
|
|
|
|
it("should get page of previous chapter", function()
|
|
|
|
|
assert.are.same(9, toc:getPreviousChapter(10, 0))
|
|
|
|
|
assert.are.same(95, toc:getPreviousChapter(100, 0))
|
|
|
|
|
assert.are.same(190, toc:getPreviousChapter(200, 0))
|
|
|
|
|
assert.are.same(8, toc:getPreviousChapter(10, 0))
|
|
|
|
|
assert.are.same(99, toc:getPreviousChapter(100, 0))
|
|
|
|
|
assert.are.same(181, toc:getPreviousChapter(200, 0))
|
|
|
|
|
end)
|
|
|
|
|
it("should get page left of chapter", function()
|
|
|
|
|
assert.are.same(14, toc:getChapterPagesLeft(10, 0))
|
|
|
|
|
assert.are.same(2, toc:getChapterPagesLeft(100, 0))
|
|
|
|
|
assert.are.same(12, toc:getChapterPagesLeft(10, 0))
|
|
|
|
|
assert.are.same(11, toc:getChapterPagesLeft(100, 0))
|
|
|
|
|
assert.are.same(nil, toc:getChapterPagesLeft(200, 0))
|
|
|
|
|
end)
|
|
|
|
|
it("should get page done of chapter", function()
|
|
|
|
|
assert.are.same(1, toc:getChapterPagesDone(10, 0))
|
|
|
|
|
assert.are.same(0, toc:getChapterPagesDone(100, 0))
|
|
|
|
|
assert.are.same(10, toc:getChapterPagesDone(200, 0))
|
|
|
|
|
assert.are.same(2, toc:getChapterPagesDone(10, 0))
|
|
|
|
|
assert.are.same(1, toc:getChapterPagesDone(100, 0))
|
|
|
|
|
assert.are.same(19, toc:getChapterPagesDone(200, 0))
|
|
|
|
|
end)
|
|
|
|
|
describe("collasible TOC", function()
|
|
|
|
|
it("should collapse the secondary toc nodes by default", function()
|
|
|
|
|