aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/server_requests_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/api/server_requests_spec.lua')
-rw-r--r--test/functional/api/server_requests_spec.lua38
1 files changed, 36 insertions, 2 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index a37c41294b..a53fd8e006 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -3,8 +3,8 @@
-- be running.
local helpers = require('test.functional.helpers')
local clear, nvim, eval = helpers.clear, helpers.nvim, helpers.eval
-local eq, run, stop = helpers.eq, helpers.run, helpers.stop
-
+local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop
+local nvim_prog = helpers.nvim_prog
describe('server -> client', function()
@@ -115,4 +115,38 @@ describe('server -> client', function()
eq(expected, notified)
end)
end)
+
+ describe('when the client is a recursive vim instance', function()
+ before_each(function()
+ nvim('command', "let vim = rpcstart('"..nvim_prog.."', ['--embed'])")
+ neq(0, eval('vim'))
+ end)
+
+ after_each(function() nvim('command', 'call rpcstop(vim)') end)
+
+ it('can send/recieve notifications and make requests', function()
+ nvim('command', "call rpcnotify(vim, 'vim_set_current_line', 'SOME TEXT')")
+
+ -- Wait for the notification to complete.
+ nvim('command', "call rpcrequest(vim, 'vim_eval', '0')")
+
+ eq('SOME TEXT', eval("rpcrequest(vim, 'vim_get_current_line')"))
+ end)
+
+ it('can communicate buffers, tabpages, and windows', function()
+ eq({3}, eval("rpcrequest(vim, 'vim_get_tabpages')"))
+ eq({1}, eval("rpcrequest(vim, 'vim_get_windows')"))
+
+ local buf = eval("rpcrequest(vim, 'vim_get_buffers')")[1]
+ eq(2, buf)
+
+ eval("rpcnotify(vim, 'buffer_set_line', "..buf..", 0, 'SOME TEXT')")
+ nvim('command', "call rpcrequest(vim, 'vim_eval', '0')") -- wait
+
+ eq('SOME TEXT', eval("rpcrequest(vim, 'buffer_get_line', "..buf..", 0)"))
+
+ -- Call get_line_slice(buf, range [0,0], includes start, includes end)
+ eq({'SOME TEXT'}, eval("rpcrequest(vim, 'buffer_get_line_slice', "..buf..", 0, 0, 1, 1)"))
+ end)
+ end)
end)