mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
local n = require('test.functional.testnvim')()
 | 
						|
local Screen = require('test.functional.ui.screen')
 | 
						|
 | 
						|
local clear = n.clear
 | 
						|
local command = n.command
 | 
						|
local feed = n.feed
 | 
						|
 | 
						|
describe('update_menu notification', function()
 | 
						|
  local screen
 | 
						|
 | 
						|
  before_each(function()
 | 
						|
    clear()
 | 
						|
    screen = Screen.new()
 | 
						|
    screen:attach()
 | 
						|
  end)
 | 
						|
 | 
						|
  local function expect_sent(expected)
 | 
						|
    screen:expect {
 | 
						|
      condition = function()
 | 
						|
        if screen.update_menu ~= expected then
 | 
						|
          if expected then
 | 
						|
            error('update_menu was expected but not sent')
 | 
						|
          else
 | 
						|
            error('update_menu was sent unexpectedly')
 | 
						|
          end
 | 
						|
        end
 | 
						|
      end,
 | 
						|
      unchanged = not expected,
 | 
						|
    }
 | 
						|
  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)
 |