From 5a9b2fc1ae4964a59f6e88487a24e29f6544ba64 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 4 Oct 2015 14:54:30 -0400 Subject: [PATCH] test: menu_spec: avoid screen test. Redraw can be flaky especially when remote commands happen during command-mode. Assert the state directly instead of using Screen. --- test/functional/ex_cmds/menu_spec.lua | 45 +++++++++++++-------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/test/functional/ex_cmds/menu_spec.lua b/test/functional/ex_cmds/menu_spec.lua index 8f4a195fd7..f5fd30465d 100644 --- a/test/functional/ex_cmds/menu_spec.lua +++ b/test/functional/ex_cmds/menu_spec.lua @@ -1,9 +1,7 @@ local helpers = require('test.functional.helpers') -local Screen = require('test.functional.ui.screen').new(40,4) local clear, execute, nvim = helpers.clear, helpers.execute, helpers.nvim -local expect = helpers.expect -local feed = helpers.feed -local command = helpers.command +local expect, feed, command = helpers.expect, helpers.feed, helpers.command +local eq, eval = helpers.eq, helpers.eval describe(':emenu', function() @@ -12,6 +10,10 @@ describe(':emenu', function() execute('nnoremenu Test.Test inormal') execute('inoremenu Test.Test insert') execute('vnoremenu Test.Test x') + execute('cnoremenu Test.Test cmdmode') + + execute('nnoremenu Edit.Paste p') + execute('cnoremenu Edit.Paste "') end) it('executes correct bindings in normal mode without using API', function() @@ -36,26 +38,21 @@ describe(':emenu', function() expect('ae') end) -end) + it('executes correct bindings in command mode', function() + feed('ithis is a sentence^"+yiwo') -describe('emenu Edit.Paste while in commandline', function() - before_each(function() - clear() - screen = Screen.new(40, 4) - screen:attach() - end) + -- Invoke "Edit.Paste" in normal-mode. + nvim('command', 'emenu Edit.Paste') - it('ok', function() - nvim('command', 'runtime menu.vim') - feed('ithis is a sentence^"+yiwo') - nvim('command', 'emenu Edit.Paste') - feed(':') - nvim('command', 'emenu Edit.Paste') - screen:expect([[ - this is a sentence | - this | - ~ | - :this^ | - ]]) - end) + -- Invoke "Edit.Paste" and "Test.Test" in command-mode. + feed(':') + nvim('command', 'emenu Edit.Paste') + nvim('command', 'emenu Test.Test') + + expect([[ + this is a sentence + this]]) + -- Assert that Edit.Paste pasted @" into the commandline. + eq('thiscmdmode', eval('getcmdline()')) + end) end)