|
|
@ -16,10 +16,10 @@ describe("Readertoc module", function()
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should get toc title from page", function()
|
|
|
|
it("should get toc title from page", function()
|
|
|
|
local title = toc:getTocTitleByPage(51)
|
|
|
|
local title = toc:getTocTitleByPage(51)
|
|
|
|
--DEBUG("toc", toc.toc)
|
|
|
|
DEBUG("toc", toc.toc)
|
|
|
|
assert(title == "Prologue")
|
|
|
|
assert(title == "SCENE V. A hall in Capulet's house.")
|
|
|
|
local title = toc:getTocTitleByPage(155)
|
|
|
|
local title = toc:getTocTitleByPage(155)
|
|
|
|
assert(title == "SCENE IV. Hall in Capulet's house.")
|
|
|
|
assert(title == "SCENE I. Friar Laurence's cell.")
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
describe("getTocTicks API", function()
|
|
|
|
describe("getTocTicks API", function()
|
|
|
|
local ticks_level_0 = nil
|
|
|
|
local ticks_level_0 = nil
|
|
|
@ -50,24 +50,24 @@ describe("Readertoc module", function()
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should get page of next chapter", function()
|
|
|
|
it("should get page of next chapter", function()
|
|
|
|
assert.are.same(23, toc:getNextChapter(10, 0))
|
|
|
|
assert.are.same(24, toc:getNextChapter(10, 0))
|
|
|
|
assert.are.same(106, toc:getNextChapter(100, 0))
|
|
|
|
assert.are.same(113, toc:getNextChapter(100, 0))
|
|
|
|
assert.are.same(nil, toc:getNextChapter(200, 0))
|
|
|
|
assert.are.same(nil, toc:getNextChapter(200, 0))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should get page of previous chapter", function()
|
|
|
|
it("should get page of previous chapter", function()
|
|
|
|
assert.are.same(8, toc:getPreviousChapter(10, 0))
|
|
|
|
assert.are.same(8, toc:getPreviousChapter(10, 0))
|
|
|
|
assert.are.same(94, toc:getPreviousChapter(100, 0))
|
|
|
|
assert.are.same(97, toc:getPreviousChapter(100, 0))
|
|
|
|
assert.are.same(174, toc:getPreviousChapter(200, 0))
|
|
|
|
assert.are.same(182, toc:getPreviousChapter(200, 0))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should get page left of chapter", function()
|
|
|
|
it("should get page left of chapter", function()
|
|
|
|
assert.are.same(12, toc:getChapterPagesLeft(10, 0))
|
|
|
|
assert.are.same(13, toc:getChapterPagesLeft(10, 0))
|
|
|
|
assert.are.same(5, toc:getChapterPagesLeft(100, 0))
|
|
|
|
assert.are.same(12, toc:getChapterPagesLeft(100, 0))
|
|
|
|
assert.are.same(nil, toc:getChapterPagesLeft(200, 0))
|
|
|
|
assert.are.same(nil, toc:getChapterPagesLeft(200, 0))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
it("should get page done of chapter", function()
|
|
|
|
it("should get page done of chapter", function()
|
|
|
|
assert.are.same(2, toc:getChapterPagesDone(10, 0))
|
|
|
|
assert.are.same(2, toc:getChapterPagesDone(10, 0))
|
|
|
|
assert.are.same(6, toc:getChapterPagesDone(100, 0))
|
|
|
|
assert.are.same(0, toc:getChapterPagesDone(100, 0))
|
|
|
|
assert.are.same(26, toc:getChapterPagesDone(200, 0))
|
|
|
|
assert.are.same(18, toc:getChapterPagesDone(200, 0))
|
|
|
|
end)
|
|
|
|
end)
|
|
|
|
describe("collasible TOC", function()
|
|
|
|
describe("collasible TOC", function()
|
|
|
|
it("should collapse the secondary toc nodes by default", function()
|
|
|
|
it("should collapse the secondary toc nodes by default", function()
|
|
|
|