mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
update readersearch and readertoc specs as crengine is updated
This commit is contained in:
@@ -53,7 +53,7 @@ describe("Readersearch module", function()
|
||||
local words = search:searchFromStart("Verona")
|
||||
assert.truthy(words)
|
||||
local pageno = doc:getPageFromXPointer(words[1].start)
|
||||
assert.are.equal(8, pageno)
|
||||
assert.are.equal(7, pageno)
|
||||
end
|
||||
for i = 1, 5, 1 do
|
||||
rolling:gotoPage(i)
|
||||
@@ -62,12 +62,12 @@ describe("Readersearch module", function()
|
||||
end
|
||||
end)
|
||||
it("should find the last occurrence", function()
|
||||
for i = 100, 200, 10 do
|
||||
for i = 100, 180, 10 do
|
||||
rolling:gotoPage(i)
|
||||
local words = search:searchFromEnd("Verona")
|
||||
assert.truthy(words)
|
||||
local pageno = doc:getPageFromXPointer(words[1].start)
|
||||
assert.are.equal(208, pageno)
|
||||
assert.are.equal(198, pageno)
|
||||
end
|
||||
for i = 230, 235, 1 do
|
||||
rolling:gotoPage(i)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user