aboutsummaryrefslogtreecommitdiff
path: root/test/functional/terminal/window_split_tab_spec.lua
blob: c5199f620eea055f4d5add4ff1f8cdcbfe00f84f (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
local helpers = require('test.functional.helpers')(after_each)
local thelpers = require('test.functional.terminal.helpers')
local clear = helpers.clear
local feed, nvim = helpers.feed, helpers.nvim
local feed_command = helpers.feed_command

describe('terminal', function()
  local screen

  before_each(function()
    clear()
    -- set the statusline to a constant value because of variables like pid
    -- and current directory and to improve visibility of splits
    nvim('set_option', 'statusline', '==========')
    nvim('command', 'highlight StatusLine cterm=NONE')
    nvim('command', 'highlight StatusLineNC cterm=NONE')
    nvim('command', 'highlight VertSplit cterm=NONE')
    screen = thelpers.screen_setup(3)
  end)

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

  it('resets its size when entering terminal window', function()
    if helpers.pending_win32(pending) then return end
    feed('<c-\\><c-n>')
    feed_command('2split')
    screen:expect([[
      rows: 2, cols: 50                                 |
      {2:^ }                                                 |
      ==========                                        |
      rows: 2, cols: 50                                 |
      {2: }                                                 |
      {4:~                                                 }|
      {4:~                                                 }|
      {4:~                                                 }|
      ==========                                        |
      :2split                                           |
    ]])
    feed_command('wincmd p')
    screen:expect([[
      tty ready                                         |
      rows: 2, cols: 50                                 |
      ==========                                        |
      tty ready                                         |
      rows: 2, cols: 50                                 |
      rows: 5, cols: 50                                 |
      {2: }                                                 |
      ^                                                  |
      ==========                                        |
      :wincmd p                                         |
    ]])
    feed_command('wincmd p')
    screen:expect([[
      rows: 2, cols: 50                                 |
      {2:^ }                                                 |
      ==========                                        |
      rows: 2, cols: 50                                 |
      {2: }                                                 |
      {4:~                                                 }|
      {4:~                                                 }|
      {4:~                                                 }|
      ==========                                        |
      :wincmd p                                         |
    ]])
  end)

  describe('when the screen is resized', function()
    it('will forward a resize request to the program', function()
      feed([[<C-\><C-N>:]])  -- Go to cmdline-mode, so cursor is at bottom.
      screen:try_resize(screen._width - 3, screen._height - 2)
      screen:expect([[
        tty ready                                      |
        rows: 7, cols: 47                              |
        {2: }                                              |
                                                       |
                                                       |
                                                       |
                                                       |
        :^                                              |
      ]])
      screen:try_resize(screen._width - 6, screen._height - 3)
      screen:expect([[
        tty ready                                |
        rows: 7, cols: 47                        |
        rows: 4, cols: 41                        |
        {2: }                                        |
        :^                                        |
      ]])
    end)
  end)
end)