aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/tabline_spec.lua
blob: aa7b432c092a0093d45ededb8e5a8cce6d1a7370 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq

describe('ui/tabline', function()
  local screen
  local tabs, curtab

  before_each(function()
    clear()
    screen = Screen.new(25, 5)
    screen:attach({rgb=true, ext_tabline=true})
    screen:set_on_event_handler(function(name, data)
      if name == "tabline_update" then
        curtab, tabs = unpack(data)
      end
    end)
  end)

  after_each(function()
    screen:detach()
  end)

  describe('externalized', function()
    it('publishes UI events', function()
      local expected = {
        {1, {['name'] = '[No Name]'}},
        {2, {['name'] = '[No Name]'}},
      }
      feed(":tabnew<CR>")
      screen:expect([[
        ^                         |
        ~                        |
        ~                        |
        ~                        |
                                 |
      ]], nil, nil, function()
        eq(2, curtab)
        eq(expected, tabs)
      end)

      feed(":tabNext<CR>")
      screen:expect([[
        ^                         |
        ~                        |
        ~                        |
        ~                        |
                                 |
      ]], nil, nil, function()
        eq(1, curtab)
        eq(expected, tabs)
      end)

    end)
  end)
end)