diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-03-03 10:26:11 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2019-03-03 13:09:43 +0100 |
commit | c8f310825cf92da2feb25a7298998fcd1da5a769 (patch) | |
tree | ab7ef5b75a2206f038d428798a788b5f7d6cc848 /test/functional/api | |
parent | 7a6da502b9d8deecfc89d1497a8e8da15e65f31e (diff) | |
download | rneovim-c8f310825cf92da2feb25a7298998fcd1da5a769.tar.gz rneovim-c8f310825cf92da2feb25a7298998fcd1da5a769.tar.bz2 rneovim-c8f310825cf92da2feb25a7298998fcd1da5a769.zip |
api: add nvim_win_close() to close window by id
Diffstat (limited to 'test/functional/api')
-rw-r--r-- | test/functional/api/window_spec.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 4496e1f644..4ff299cd18 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -286,4 +286,41 @@ describe('API/win', function() ok(not window('is_valid', win)) end) end) + + describe('close', function() + it('can close current window', function() + local oldwin = meths.get_current_win() + command('split') + local newwin = meths.get_current_win() + meths.win_close(newwin,false) + eq({oldwin}, meths.list_wins()) + end) + + it('can close noncurrent window', function() + local oldwin = meths.get_current_win() + command('split') + local newwin = meths.get_current_win() + meths.win_close(oldwin,false) + eq({newwin}, meths.list_wins()) + end) + + it('handles changed buffer', function() + local oldwin = meths.get_current_win() + insert('text') + command('new') + local newwin = meths.get_current_win() + eq({false,"Vim:E37: No write since last change (add ! to override)"}, + meth_pcall(meths.win_close, oldwin,false)) + eq({newwin,oldwin}, meths.list_wins()) + end) + + it('handles changed buffer with force', function() + local oldwin = meths.get_current_win() + insert('text') + command('new') + local newwin = meths.get_current_win() + meths.win_close(oldwin,true) + eq({newwin}, meths.list_wins()) + end) + end) end) |