menu_spec.lua 1.1 KB

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