neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

054_buffer_local_autocommands_spec.lua (907B)


      1 -- Some tests for buffer-local autocommands
      2 
      3 local n = require('test.functional.testnvim')()
      4 
      5 local clear = n.clear
      6 local expect = n.expect
      7 local command = n.command
      8 
      9 local fname = 'Xtest-functional-legacy-054'
     10 
     11 describe('BufLeave <buffer>', function()
     12  setup(clear)
     13 
     14  it('is working', function()
     15    command('write! ' .. fname)
     16    command('autocmd BufLeave <buffer> normal! Ibuffer-local autocommand')
     17    command('autocmd BufLeave <buffer> update')
     18 
     19    -- Here, autocommand for xx shall append a line
     20    -- But autocommand shall not apply to buffer named <buffer>
     21    command('edit somefile')
     22 
     23    -- Here, autocommand shall be auto-deleted
     24    command('bwipeout ' .. fname)
     25 
     26    -- Nothing shall be written
     27    command('edit ' .. fname)
     28    command('edit somefile')
     29    command('edit ' .. fname)
     30 
     31    expect('buffer-local autocommand')
     32  end)
     33 
     34  teardown(function()
     35    os.remove(fname)
     36  end)
     37 end)