menu_spec.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. local n = require('test.functional.testnvim')()
  2. local Screen = require('test.functional.ui.screen')
  3. local clear = n.clear
  4. local command = n.command
  5. local feed = n.feed
  6. describe('update_menu notification', function()
  7. local screen
  8. before_each(function()
  9. clear()
  10. screen = Screen.new()
  11. end)
  12. local function expect_sent(expected)
  13. screen:expect {
  14. condition = function()
  15. if screen.update_menu ~= expected then
  16. if expected then
  17. error('update_menu was expected but not sent')
  18. else
  19. error('update_menu was sent unexpectedly')
  20. end
  21. end
  22. end,
  23. unchanged = not expected,
  24. }
  25. end
  26. it('should be sent when adding a menu', function()
  27. command('menu Test.Test :')
  28. expect_sent(true)
  29. end)
  30. it('should be sent when deleting a menu', function()
  31. command('menu Test.Test :')
  32. screen.update_menu = false
  33. command('unmenu Test.Test')
  34. expect_sent(true)
  35. end)
  36. it('should not be sent unnecessarily', function()
  37. feed('i12345<ESC>:redraw<CR>')
  38. expect_sent(false)
  39. end)
  40. end)