aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2015-02-16 23:24:31 -0500
committerJustin M. Keyes <justinkz@gmail.com>2015-02-16 23:24:31 -0500
commit662b7227b54d18c0113741edff157cd8648c2594 (patch)
treeaa35b1fcb2e89f4f11976edb4e32b315f746e168 /test
parent0429857689ba98356bc80d01ebd540fe861e8db2 (diff)
parent3ffc5d81c34cfdd535573a50790690c88e4324bb (diff)
downloadrneovim-662b7227b54d18c0113741edff157cd8648c2594.tar.gz
rneovim-662b7227b54d18c0113741edff157cd8648c2594.tar.bz2
rneovim-662b7227b54d18c0113741edff157cd8648c2594.zip
Merge #1717 'TabNew, TabNewEntered, TabClosed'
Diffstat (limited to 'test')
-rw-r--r--test/functional/autocmd/tabclose_spec.lua36
-rw-r--r--test/functional/autocmd/tabnew_spec.lua24
-rw-r--r--test/functional/autocmd/tabnewentered_spec.lua24
3 files changed, 84 insertions, 0 deletions
diff --git a/test/functional/autocmd/tabclose_spec.lua b/test/functional/autocmd/tabclose_spec.lua
new file mode 100644
index 0000000000..847362e3de
--- /dev/null
+++ b/test/functional/autocmd/tabclose_spec.lua
@@ -0,0 +1,36 @@
+local helpers = require('test.functional.helpers')
+local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
+ helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
+ helpers.eq, helpers.neq, helpers.ok
+
+describe('TabClosed', function()
+ describe('au TabClosed', function()
+ describe('with * as <afile>', function()
+ it('matches when closing any tab', function()
+ clear()
+ nvim('command', 'au! TabClosed * echom "tabclosed:".expand("<afile>").":".expand("<amatch>").":".tabpagenr()')
+ repeat
+ nvim('command', 'tabnew')
+ until nvim('eval', 'tabpagenr()') == 6 -- current tab is now 6
+ eq("\ntabclosed:6:6:5", nvim('command_output', 'tabclose')) -- close last 6, current tab is now 5
+ eq("\ntabclosed:5:5:4", nvim('command_output', 'close')) -- close last window on tab, closes tab
+ eq("\ntabclosed:2:2:3", nvim('command_output', '2tabclose')) -- close tab 2, current tab is now 3
+ eq("\ntabclosed:1:1:2\ntabclosed:1:1:1", nvim('command_output', 'tabonly')) -- close tabs 1 and 2
+ end)
+ end)
+ describe('with NR as <afile>', function()
+ it('matches when closing a tab whose index is NR', function()
+ tmp_path = nvim('eval', 'tempname()')
+ nvim('command', 'au! TabClosed 2 echom "tabclosed:match"')
+ repeat
+ nvim('command', 'tabnew')
+ until nvim('eval', 'tabpagenr()') == 5 -- current tab is now 5
+ -- sanity check, we shouldn't match on tabs with numbers other than 2
+ eq("\ntabclosed:5:5:4", nvim('command_output', 'tabclose'))
+ -- close tab page 2, current tab is now 3
+ eq("\ntabclosed:2:2:3\ntabclosed:match", nvim('command_output', '2tabclose'))
+ end)
+ end)
+ end)
+end)
+
diff --git a/test/functional/autocmd/tabnew_spec.lua b/test/functional/autocmd/tabnew_spec.lua
new file mode 100644
index 0000000000..970ca19726
--- /dev/null
+++ b/test/functional/autocmd/tabnew_spec.lua
@@ -0,0 +1,24 @@
+local helpers = require('test.functional.helpers')
+local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
+ helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
+ helpers.eq, helpers.neq, helpers.ok
+
+describe('TabNew', function()
+ describe('au TabNew', function()
+ clear()
+ describe('with * as <afile>', function()
+ it('matches when opening any new tab', function()
+ nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")')
+ eq("\ntabnew:2:1", nvim('command_output', 'tabnew'))
+ eq("\ntabnew:3:2\n\"test.x\" [New File]", nvim('command_output', 'tabnew test.x'))
+ end)
+ end)
+ describe('with FILE as <afile>', function()
+ it('matches when opening a new tab for FILE', function()
+ tmp_path = nvim('eval', 'tempname()')
+ nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"')
+ eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path))
+ end)
+ end)
+ end)
+end)
diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua
new file mode 100644
index 0000000000..f220c15ef7
--- /dev/null
+++ b/test/functional/autocmd/tabnewentered_spec.lua
@@ -0,0 +1,24 @@
+local helpers = require('test.functional.helpers')
+local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
+ helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
+ helpers.eq, helpers.neq, helpers.ok
+
+describe('TabNewEntered', function()
+ describe('au TabNewEntered', function()
+ describe('with * as <afile>', function()
+ it('matches when entering any new tab', function()
+ clear()
+ nvim('command', 'au! TabNewEntered * echom "tabnewentered:".tabpagenr().":".bufnr("")')
+ eq("\ntabnewentered:2:2", nvim('command_output', 'tabnew'))
+ eq("\n\"test.x2\" [New File]\ntabnewentered:3:3", nvim('command_output', 'tabnew test.x2'))
+ end)
+ end)
+ describe('with FILE as <afile>', function()
+ it('matches when opening a new tab for FILE', function()
+ tmp_path = nvim('eval', 'tempname()')
+ nvim('command', 'au! TabNewEntered '..tmp_path..' echom "tabnewentered:match"')
+ eq("\n\""..tmp_path.."\" [New File]\ntabnewentered:4:4\ntabnewentered:match", nvim('command_output', 'tabnew '..tmp_path))
+ end)
+ end)
+ end)
+end)