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