robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

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