diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-04-04 17:47:23 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-04-06 01:06:39 +0200 |
commit | 3b558e5d7b8c641896a57c5c4e09d9b8f8535fd5 (patch) | |
tree | 47a485a9855043c1c751b770b8f2820e867a4023 /test/functional/ui/cursor_spec.lua | |
parent | 4566f7c7cda2c3a181ec58998f7c93dd17500153 (diff) | |
download | rneovim-3b558e5d7b8c641896a57c5c4e09d9b8f8535fd5.tar.gz rneovim-3b558e5d7b8c641896a57c5c4e09d9b8f8535fd5.tar.bz2 rneovim-3b558e5d7b8c641896a57c5c4e09d9b8f8535fd5.zip |
tests: short form `screen:except(func)` expects condition only. #6440
- Use this to properly test cursor shape events.
- tests: update screen_basic_spec to use `screen:expect` short form.
Clearer than using `screen:wait` directy.
Diffstat (limited to 'test/functional/ui/cursor_spec.lua')
-rw-r--r-- | test/functional/ui/cursor_spec.lua | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 3ec3ffd08c..02e9422781 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -3,7 +3,6 @@ local Screen = require('test.functional.ui.screen') local clear, meths = helpers.clear, helpers.meths local eq = helpers.eq local command = helpers.command -local wait = helpers.wait describe('ui/cursor', function() local screen @@ -19,8 +18,6 @@ describe('ui/cursor', function() end) it("'guicursor' is published as a UI event", function() - wait() - screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. local expected_cursor_style = { cmdline_hover = { mouse_shape = 0, @@ -142,44 +139,54 @@ describe('ui/cursor', function() vsep_hover = { mouse_shape = 0, short_name = 'vs' } - } - -- Default 'guicursor' published on startup. - eq(expected_cursor_style, screen._cursor_style) - eq(true, screen._cursor_style_enabled) - eq('normal', screen.mode) + } + + screen:expect(function() + -- Default 'guicursor' published on startup. + eq(expected_cursor_style, screen._cursor_style) + eq(true, screen._cursor_style_enabled) + eq('normal', screen.mode) + end) -- Event is published ONLY if the cursor style changed. screen._cursor_style = nil - wait() - screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. - eq(nil, screen._cursor_style) + command("echo 'test'") + screen:expect([[ + ^ | + ~ | + ~ | + ~ | + test | + ]], nil, nil, function() + eq(nil, screen._cursor_style) + end) -- Change the cursor style. meths.set_option('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173,ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42') - wait() - screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. - eq('vertical', screen._cursor_style.normal.cursor_shape) - eq('horizontal', screen._cursor_style.visual_select.cursor_shape) - eq('vertical', screen._cursor_style.operator.cursor_shape) - eq('block', screen._cursor_style.insert.cursor_shape) - eq('vertical', screen._cursor_style.showmatch.cursor_shape) - eq(171, screen._cursor_style.normal.blinkwait) - eq(172, screen._cursor_style.normal.blinkoff) - eq(173, screen._cursor_style.normal.blinkon) + screen:expect(function() + eq('vertical', screen._cursor_style.normal.cursor_shape) + eq('horizontal', screen._cursor_style.visual_select.cursor_shape) + eq('vertical', screen._cursor_style.operator.cursor_shape) + eq('block', screen._cursor_style.insert.cursor_shape) + eq('vertical', screen._cursor_style.showmatch.cursor_shape) + eq(171, screen._cursor_style.normal.blinkwait) + eq(172, screen._cursor_style.normal.blinkoff) + eq(173, screen._cursor_style.normal.blinkon) + end) end) it("empty 'guicursor' sets cursor_shape=block in all modes", function() meths.set_option('guicursor', '') - command('redraw') - screen:expect('', nil, nil, nil, true) -- Tickle the event-loop. - -- Empty 'guicursor' sets enabled=false. - eq(false, screen._cursor_style_enabled) - for _, m in ipairs({ 'cmdline_insert', 'cmdline_normal', 'cmdline_replace', 'insert', - 'showmatch', 'normal', 'replace', 'visual', - 'visual_select', }) do - eq('block', screen._cursor_style[m].cursor_shape) - eq(0, screen._cursor_style[m].blinkon) - end + screen:expect(function() + -- Empty 'guicursor' sets enabled=false. + eq(false, screen._cursor_style_enabled) + for _, m in ipairs({ 'cmdline_insert', 'cmdline_normal', 'cmdline_replace', 'insert', + 'showmatch', 'normal', 'replace', 'visual', + 'visual_select', }) do + eq('block', screen._cursor_style[m].cursor_shape) + eq(0, screen._cursor_style[m].blinkon) + end + end) end) end) |