~ubuntu-branches/debian/sid/neovim/sid

« back to all changes in this revision

Viewing changes to test/functional/autocmd/tabnew_spec.lua

  • Committer: Package Import Robot
  • Author(s): James McCoy
  • Date: 2016-04-18 21:42:19 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20160418214219-1e6d4o1fwqarzk46
Tags: 0.1.3-1
* New upstream release.  (Closes: #820562)
* debian/control:
  + Remove unnecessary luarocks Build-Depends
  + Add libkvm-dev Build-Depends for kfreebsd-*
  + Add python(3)-neovim to Recommends.  (Closes: #812737)
  + Declare compiance with policy 3.9.8, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
local helpers = require('test.functional.helpers')
2
 
local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
3
 
 
4
 
describe('TabNew', function()
5
 
    setup(clear)
6
 
    describe('au TabNew', function()
7
 
        describe('with * as <afile>', function()
8
 
            it('matches when opening any new tab', function()
9
 
                nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")')
10
 
                eq("\ntabnew:2:1", nvim('command_output', 'tabnew'))
11
 
                eq("\ntabnew:3:2\n\"test.x\" [New File]", nvim('command_output', 'tabnew test.x'))
12
 
            end)
13
 
        end)
14
 
        describe('with FILE as <afile>', function()
15
 
            it('matches when opening a new tab for FILE', function()
16
 
                local tmp_path = nvim('eval', 'tempname()')
17
 
                nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"')
18
 
                eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path))
19
 
           end)
20
 
        end)
21
 
    end)
 
2
 
 
3
local clear = helpers.clear
 
4
local command = helpers.command
 
5
local eq = helpers.eq
 
6
local eval = helpers.eval
 
7
 
 
8
describe('autocmd TabNew', function()
 
9
  before_each(clear)
 
10
 
 
11
  it('matches when opening any new tab', function()
 
12
    command('autocmd! TabNew * let g:test = "tabnew:".tabpagenr().":".bufnr("")')
 
13
    command('tabnew')
 
14
    eq('tabnew:2:1', eval('g:test'))
 
15
    command('tabnew test.x')
 
16
    eq('tabnew:3:2', eval('g:test'))
 
17
  end)
 
18
 
 
19
  it('matches when opening a new tab for FILE', function()
 
20
    local tmp_path = helpers.funcs.tempname()
 
21
    command('let g:test = "foo"')
 
22
    command('autocmd! TabNew ' .. tmp_path .. ' let g:test = "bar"')
 
23
    command('tabnew ' .. tmp_path ..'X')
 
24
    eq('foo', eval('g:test'))
 
25
    command('tabnew ' .. tmp_path)
 
26
    eq('bar', eval('g:test'))
 
27
  end)
22
28
end)