aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/054_buffer_local_autocommands_spec.lua
blob: afde6f220a247b75af9b08536b74b45f5186d904 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- Some tests for buffer-local autocommands

local n = require('test.functional.testnvim')()

local clear = n.clear
local expect = n.expect
local command = n.command

local fname = 'Xtest-functional-legacy-054'

describe('BufLeave <buffer>', function()
  setup(clear)

  it('is working', function()
    command('write! ' .. fname)
    command('autocmd BufLeave <buffer> normal! Ibuffer-local autocommand')
    command('autocmd BufLeave <buffer> update')

    -- Here, autocommand for xx shall append a line
    -- But autocommand shall not apply to buffer named <buffer>
    command('edit somefile')

    -- Here, autocommand shall be auto-deleted
    command('bwipeout ' .. fname)

    -- Nothing shall be written
    command('edit ' .. fname)
    command('edit somefile')
    command('edit ' .. fname)

    expect('buffer-local autocommand')
  end)

  teardown(function()
    os.remove(fname)
  end)
end)