robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

master
2.7 KiB83 linesraw
1local t = require('test.testutil')
2local n = require('test.functional.testnvim')()
3
4local tt = require('test.functional.testterm')
5local describe, it, before_each, after_each = t.describe, t.it, t.before_each, t.after_each
6local ok = t.ok
7
8if t.skip(t.is_os('win')) then
9  return
10end
11
12describe('api', function()
13  local screen
14  local socket_name = './Xtest_functional_api.sock'
15
16  before_each(function()
17    n.clear()
18    os.remove(socket_name)
19    screen = tt.setup_child_nvim({
20      '-u',
21      'NONE',
22      '-i',
23      'NONE',
24      '--cmd',
25      'colorscheme vim',
26      '--cmd',
27      n.nvim_set .. ' notermguicolors',
28    })
29  end)
30  after_each(function()
31    os.remove(socket_name)
32  end)
33
34  it('qa! RPC request during insert-mode', function()
35    screen:expect([[
36      ^                                                  |
37      {100:~                                                 }|*4
38                                                        |
39      {5:-- TERMINAL --}                                    |
40    ]])
41
42    -- Start the socket from the child nvim.
43    tt.feed_data(":echo serverstart('" .. socket_name .. "')\n")
44
45    -- Wait for socket creation.
46    screen:expect([[
47      ^                                                  |
48      {100:~                                                 }|*4
49      ]] .. socket_name .. [[                       |
50      {5:-- TERMINAL --}                                    |
51    ]])
52
53    local socket_session1 = n.connect(socket_name)
54    local socket_session2 = n.connect(socket_name)
55
56    tt.feed_data('i[tui] insert-mode')
57    -- Wait for stdin to be processed.
58    screen:expect([[
59      [tui] insert-mode^                                 |
60      {100:~                                                 }|*4
61      {5:-- INSERT --}                                      |
62      {5:-- TERMINAL --}                                    |
63    ]])
64
65    ok((socket_session1:request('nvim_ui_attach', 42, 6, { rgb = true })))
66    ok((socket_session2:request('nvim_ui_attach', 25, 30, { rgb = true })))
67
68    socket_session1:notify('nvim_input', '\n[socket 1] this is more than 25 columns')
69    socket_session2:notify('nvim_input', '\n[socket 2] input')
70
71    screen:expect([[
72      [tui] insert-mode                                 |
73      [socket 1] this is more t                         |
74      han 25 columns                                    |
75      [socket 2] input^                                  |
76      {100:~                        }                         |
77      {5:-- INSERT --}                                      |
78      {5:-- TERMINAL --}                                    |
79    ]])
80
81    socket_session1:request('nvim_command', 'qa!')
82  end)
83end)