2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00
koreader/spec/unit/readerpaging_spec.lua

51 lines
1.6 KiB
Lua
Raw Normal View History

describe("Readerpaging module", function()
local sample_pdf = "spec/front/unit/data/sample.pdf"
local readerui
local paging
setup(function() require("commonrequire") end)
describe("Page mode", function()
setup(function()
readerui = require("apps/reader/readerui"):new{
document = require("document/documentregistry"):openDocument(sample_pdf),
}
paging = readerui.paging
end)
it("should emit EndOfBook event at the end", function()
readerui.zooming:setZoomMode("pageheight")
paging:onGotoPage(readerui.document:getPageCount())
local called = false
readerui.onEndOfBook = function()
called = true
end
paging:onPagingRel(1)
assert.is.truthy(called)
readerui.onEndOfBook = nil
end)
end)
describe("Scroll mode", function()
setup(function()
readerui = require("apps/reader/readerui"):new{
document = require("document/documentregistry"):openDocument(sample_pdf),
}
paging = readerui.paging
end)
it("should emit EndOfBook event at the end", function()
paging:onGotoPage(readerui.document:getPageCount())
readerui.zooming:setZoomMode("pageheight")
readerui.view:onSetScrollMode(true)
local called = false
readerui.onEndOfBook = function()
called = true
end
paging:onPagingRel(1)
assert.is.truthy(called)
readerui.onEndOfBook = nil
end)
end)
end)