mirror of https://github.com/koreader/koreader
test: add spec for Menu.itemTableFromTouchMenu
parent
1340ba8e62
commit
df61760c82
@ -0,0 +1,35 @@
|
||||
require("commonrequire")
|
||||
local Menu = require("ui/widget/menu")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
describe("Menu widget", function()
|
||||
it("should convert item table from touch menu properly", function()
|
||||
local cb1 = function() end
|
||||
local cb2 = function() end
|
||||
re = Menu.itemTableFromTouchMenu({
|
||||
navi = {
|
||||
icon = 'foo/bar.png',
|
||||
{ text = 'foo', callback = cb1 },
|
||||
{ text = 'bar', callback = cb2 },
|
||||
},
|
||||
exit = {
|
||||
icon = 'foo/bar2.png',
|
||||
callback = cb2
|
||||
},
|
||||
})
|
||||
assert.are.same(re, {
|
||||
{
|
||||
text = 'navi',
|
||||
sub_item_table = {
|
||||
icon = 'foo/bar.png',
|
||||
{ text = 'foo', callback = cb1 },
|
||||
{ text = 'bar', callback = cb2 },
|
||||
}
|
||||
},
|
||||
{
|
||||
text = 'exit',
|
||||
callback = cb2,
|
||||
}
|
||||
})
|
||||
end)
|
||||
end)
|
Loading…
Reference in New Issue