mirror of
https://github.com/neovim/neovim.git
synced 2026-07-31 04:39:07 +00:00
Problem: The magic globals `it`, `describe`, etc., are more trouble than they are worth. - Hooking into `after_each` requires `getfenv()` hacks. - They confuse luals/emmylua, because the top-level `.luarc.json` isn't merged with `test/.luarc.json` (apparently a luals limitation?) - They totally defeat discoverability because the user just has to "know" about the various magic symbols. So they harm DX, which means they serve no purpose at all. Solution: - Expose the test API from `testutil`, so tests can call `t.it()`, `t.describe()`, etc., in the conventional way. - Drop `getfenv()` hacks. - Drop the `setfenv()` injection in `load_chunk`. - Drop `test/_meta.lua`.
51 lines
1.2 KiB
Lua
51 lines
1.2 KiB
Lua
local n = require('test.functional.testnvim')()
|
|
local t = require('test.testutil')
|
|
local Screen = require('test.functional.ui.screen')
|
|
|
|
local describe, it, before_each = t.describe, t.it, t.before_each
|
|
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()
|
|
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)
|