mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
4987311fb5
It is perfectly fine and expected to detach from the screen just by the UI disconnecting from nvim or exiting nvim. Just keep detach() in screen_basic_spec, to get some coverage of the detach method itself. This avoids hang on failure in many situations (though one could argue that detach() should be "fast", or at least "as fast as resize", which works in press-return already). Never use detach() just to change the size of the screen, try_resize() method exists for that specifically.
49 lines
1.1 KiB
Lua
49 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)
|
|
|
|
local function expect_sent(expected)
|
|
screen:expect{condition=function()
|
|
if screen.update_menu ~= expected then
|
|
if expected then
|
|
error('update_menu was expected but not sent')
|
|
else
|
|
error('update_menu was sent unexpectedly')
|
|
end
|
|
end
|
|
end, unchanged=(not expected)}
|
|
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)
|