tests: cleanup ui/cmdline_spec.lua

This commit is contained in:
Björn Linse 2017-12-05 13:16:56 +01:00
parent aec81f44d1
commit 9714b9f590

View File

@ -16,6 +16,11 @@ describe('external cmdline', function()
cmdline, block = {}, nil cmdline, block = {}, nil
screen = Screen.new(25, 5) screen = Screen.new(25, 5)
screen:attach({rgb=true, ext_cmdline=true}) screen:attach({rgb=true, ext_cmdline=true})
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
[2] = {reverse = true},
[3] = {bold = true, reverse = true},
})
screen:set_on_event_handler(function(name, data) screen:set_on_event_handler(function(name, data)
if name == "cmdline_show" then if name == "cmdline_show" then
local content, pos, firstc, prompt, indent, level = unpack(data) local content, pos, firstc, prompt, indent, level = unpack(data)
@ -66,9 +71,9 @@ describe('external cmdline', function()
feed(':') feed(':')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq(1, last_level) eq(1, last_level)
@ -84,9 +89,9 @@ describe('external cmdline', function()
feed('sign') feed('sign')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -101,9 +106,9 @@ describe('external cmdline', function()
feed('<Left>') feed('<Left>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -118,9 +123,9 @@ describe('external cmdline', function()
feed('<bs>') feed('<bs>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -135,9 +140,9 @@ describe('external cmdline', function()
feed('<Esc>') feed('<Esc>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({}, cmdline) eq({}, cmdline)
@ -148,9 +153,9 @@ describe('external cmdline', function()
feed(':call input("input", "default")<cr>') feed(':call input("input", "default")<cr>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -164,9 +169,9 @@ describe('external cmdline', function()
feed('<cr>') feed('<cr>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({}, cmdline) eq({}, cmdline)
@ -178,9 +183,9 @@ describe('external cmdline', function()
feed(':xx<c-r>') feed(':xx<c-r>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -196,9 +201,9 @@ describe('external cmdline', function()
feed('=') feed('=')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -234,9 +239,9 @@ describe('external cmdline', function()
}} }}
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq(expectation, cmdline) eq(expectation, cmdline)
@ -249,9 +254,9 @@ describe('external cmdline', function()
-- focus is at external cmdline anyway. -- focus is at external cmdline anyway.
screen:expect([[ screen:expect([[
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
^ | ^ |
]], nil, nil, function() ]], nil, nil, function()
eq(expectation, cmdline) eq(expectation, cmdline)
@ -261,9 +266,9 @@ describe('external cmdline', function()
feed('<cr>') feed('<cr>')
screen:expect([[ screen:expect([[
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
^ | ^ |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -278,9 +283,9 @@ describe('external cmdline', function()
feed('<esc>') feed('<esc>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({}, cmdline) eq({}, cmdline)
@ -291,9 +296,9 @@ describe('external cmdline', function()
feed(':function Foo()<cr>') feed(':function Foo()<cr>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -309,9 +314,9 @@ describe('external cmdline', function()
feed('line1<cr>') feed('line1<cr>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{{{}, 'function Foo()'}}, eq({{{{}, 'function Foo()'}},
@ -322,9 +327,9 @@ describe('external cmdline', function()
command("redraw!") command("redraw!")
screen:expect([[ screen:expect([[
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
^ | ^ |
]], nil, nil, function() ]], nil, nil, function()
eq({{{{}, 'function Foo()'}}, eq({{{{}, 'function Foo()'}},
@ -335,9 +340,9 @@ describe('external cmdline', function()
feed('endfunction<cr>') feed('endfunction<cr>')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq(nil, block) eq(nil, block)
@ -348,9 +353,9 @@ describe('external cmdline', function()
feed(':make') feed(':make')
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -365,9 +370,9 @@ describe('external cmdline', function()
feed('<c-f>') feed('<c-f>')
screen:expect([[ screen:expect([[
| |
[No Name] | {2:[No Name] }|
:make^ | {1::}make^ |
[Command Line] | {3:[Command Line] }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({}, cmdline) eq({}, cmdline)
@ -377,9 +382,9 @@ describe('external cmdline', function()
feed(':yank') feed(':yank')
screen:expect([[ screen:expect([[
| |
[No Name] | {2:[No Name] }|
:make^ | {1::}make^ |
[Command Line] | {3:[Command Line] }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({nil, { eq({nil, {
@ -395,9 +400,9 @@ describe('external cmdline', function()
command("redraw!") command("redraw!")
screen:expect([[ screen:expect([[
| |
[No Name] | {2:[No Name] }|
:make | {1::}make |
[Command Line] | {3:[Command Line] }|
^ | ^ |
]], nil, nil, function() ]], nil, nil, function()
eq({nil, { eq({nil, {
@ -412,9 +417,9 @@ describe('external cmdline', function()
feed("<c-c>") feed("<c-c>")
screen:expect([[ screen:expect([[
| |
[No Name] | {2:[No Name] }|
:make^ | {1::}make^ |
[Command Line] | {3:[Command Line] }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({}, cmdline) eq({}, cmdline)
@ -423,9 +428,9 @@ describe('external cmdline', function()
feed("<c-c>") feed("<c-c>")
screen:expect([[ screen:expect([[
| |
[No Name] | {2:[No Name] }|
:make^ | {1::}make^ |
[Command Line] | {3:[Command Line] }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -441,9 +446,9 @@ describe('external cmdline', function()
command("redraw!") command("redraw!")
screen:expect([[ screen:expect([[
| |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
^ | ^ |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{
@ -460,9 +465,9 @@ describe('external cmdline', function()
feed(":call inputsecret('secret:')<cr>abc123") feed(":call inputsecret('secret:')<cr>abc123")
screen:expect([[ screen:expect([[
^ | ^ |
~ | {1:~ }|
~ | {1:~ }|
~ | {1:~ }|
| |
]], nil, nil, function() ]], nil, nil, function()
eq({{ eq({{