neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

menu_spec.lua (1096B)


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