menu_spec.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. local function expect_sent(expected)
  14. screen:expect{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, unchanged=(not expected)}
  23. end
  24. it("should be sent when adding a menu", function()
  25. command('menu Test.Test :')
  26. expect_sent(true)
  27. end)
  28. it("should be sent when deleting a menu", function()
  29. command('menu Test.Test :')
  30. screen.update_menu = false
  31. command('unmenu Test.Test')
  32. expect_sent(true)
  33. end)
  34. it("should not be sent unnecessarily", function()
  35. feed('i12345<ESC>:redraw<CR>')
  36. expect_sent(false)
  37. end)
  38. end)