2014-10-25 23:31:39 +00:00
|
|
|
describe("Menu widget", function()
|
2017-08-08 20:35:40 +00:00
|
|
|
local Menu
|
2016-04-21 06:16:40 +00:00
|
|
|
setup(function()
|
|
|
|
require("commonrequire")
|
|
|
|
Menu = require("ui/widget/menu")
|
|
|
|
end)
|
|
|
|
|
2014-10-25 23:31:39 +00:00
|
|
|
it("should convert item table from touch menu properly", function()
|
|
|
|
local cb1 = function() end
|
|
|
|
local cb2 = function() end
|
2017-08-08 20:35:40 +00:00
|
|
|
local re = Menu.itemTableFromTouchMenu({
|
2014-10-25 23:31:39 +00:00
|
|
|
navi = {
|
|
|
|
icon = 'foo/bar.png',
|
|
|
|
{ text = 'foo', callback = cb1 },
|
|
|
|
{ text = 'bar', callback = cb2 },
|
|
|
|
},
|
|
|
|
exit = {
|
|
|
|
icon = 'foo/bar2.png',
|
|
|
|
callback = cb2
|
|
|
|
},
|
|
|
|
})
|
2020-07-14 16:25:26 +00:00
|
|
|
--- @fixme: Currently broken because pairs (c.f., https://github.com/koreader/koreader/pull/6371#issuecomment-657251302)
|
2020-07-20 18:58:39 +00:00
|
|
|
assert.are.same({
|
|
|
|
{
|
|
|
|
text = 'exit',
|
|
|
|
callback = cb2,
|
|
|
|
},
|
2014-10-25 23:31:39 +00:00
|
|
|
{
|
|
|
|
text = 'navi',
|
|
|
|
sub_item_table = {
|
|
|
|
icon = 'foo/bar.png',
|
|
|
|
{ text = 'foo', callback = cb1 },
|
|
|
|
{ text = 'bar', callback = cb2 },
|
|
|
|
}
|
|
|
|
},
|
2020-07-20 18:58:39 +00:00
|
|
|
}, re)
|
2014-10-25 23:31:39 +00:00
|
|
|
end)
|
|
|
|
end)
|