2024-04-20 08:44:13 -07:00
|
|
|
local n = require('test.functional.testnvim')()
|
2015-07-10 16:03:30 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
local clear = n.clear
|
|
|
|
local command = n.command
|
|
|
|
local feed = n.feed
|
2015-07-10 16:03:30 -07:00
|
|
|
|
|
|
|
describe('update_menu notification', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
screen = Screen.new()
|
|
|
|
end)
|
|
|
|
|
2015-11-17 15:31:22 -07:00
|
|
|
local function expect_sent(expected)
|
2017-06-26 05:49:15 -07:00
|
|
|
screen:expect {
|
|
|
|
condition = function()
|
2015-07-10 16:03:30 -07:00
|
|
|
if screen.update_menu ~= expected then
|
|
|
|
if expected then
|
2017-06-26 05:49:15 -07:00
|
|
|
error('update_menu was expected but not sent')
|
2015-07-10 16:03:30 -07:00
|
|
|
else
|
2017-06-26 05:49:15 -07:00
|
|
|
error('update_menu was sent unexpectedly')
|
2024-01-02 18:09:18 -07:00
|
|
|
end
|
2015-07-10 16:03:30 -07:00
|
|
|
end
|
|
|
|
end,
|
2017-06-26 05:49:15 -07:00
|
|
|
unchanged = not expected,
|
|
|
|
}
|
2015-07-10 16:03:30 -07:00
|
|
|
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)
|