neovim/test/functional/api/menu_spec.lua
ZyX ff470bb853 functests: Check logs in lua code
It is otherwise impossible to determine which test failed sanitizer/valgrind
check. test/functional/helpers.lua module return was changed so that tests which
do not provide after_each function to get new check will automatically fail.
2016-06-10 21:50:49 +03:00

53 lines
1.1 KiB
Lua

local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear = helpers.clear
local command = helpers.command
local feed = helpers.feed
describe("update_menu notification", function()
local screen
before_each(function()
clear()
screen = Screen.new()
screen:attach()
end)
after_each(function()
screen:detach()
end)
local function expect_sent(expected)
screen:wait(function()
if screen.update_menu ~= expected then
if expected then
return 'update_menu was expected but not sent'
else
return 'update_menu was sent unexpectedly'
end
end
end)
end
it("should be sent when adding a menu", function()
command('menu Test.Test :')
expect_sent(true)
end)
it("should be sent when deleting a menu", function()
command('menu Test.Test :')
screen.update_menu = false
command('unmenu Test.Test')
expect_sent(true)
end)
it("should not be sent unnecessarily", function()
feed('i12345<ESC>:redraw<CR>')
expect_sent(false)
end)
end)