diff options
author | Robin Allen <r@foon.uk> | 2015-07-11 00:03:30 +0100 |
---|---|---|
committer | Robin Allen <r@foon.uk> | 2015-08-21 14:23:50 +0100 |
commit | d5b5063622ab9764a851fdf56c60d14ad0736583 (patch) | |
tree | 0300adec7e375a0c57eef58965602d0248b32e14 /test/functional/api/menu_spec.lua | |
parent | 250aca4f8938ded5bf7dfbc56904b4e696d219b1 (diff) | |
download | rneovim-d5b5063622ab9764a851fdf56c60d14ad0736583.tar.gz rneovim-d5b5063622ab9764a851fdf56c60d14ad0736583.tar.bz2 rneovim-d5b5063622ab9764a851fdf56c60d14ad0736583.zip |
Notify attached UIs whenever menus change
This adds a redraw notification "update_menu" which is sent whenever
Vim's menus are changed by the :menu command and friends.
Diffstat (limited to 'test/functional/api/menu_spec.lua')
-rw-r--r-- | test/functional/api/menu_spec.lua | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/functional/api/menu_spec.lua b/test/functional/api/menu_spec.lua new file mode 100644 index 0000000000..34d23ca098 --- /dev/null +++ b/test/functional/api/menu_spec.lua @@ -0,0 +1,52 @@ +local helpers = require('test.functional.helpers') +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) + + 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) |