aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/server_requests_spec.lua
diff options
context:
space:
mode:
authorScott Prager <splinterofchaos@gmail.com>2015-04-13 10:25:14 -0400
committerScott Prager <splinterofchaos@gmail.com>2015-04-13 10:25:14 -0400
commitd60ae3159ecb2906e53a44241a51dada359d38f0 (patch)
tree7385a2852836512c36ef67fa3fb97ba3409bfe55 /test/functional/api/server_requests_spec.lua
parenta9ee85b9fc2d4e3faa466e9c3062cd41315f8456 (diff)
parentc4da6bf2bac692c972ec9d06f8352996d563860f (diff)
downloadrneovim-d60ae3159ecb2906e53a44241a51dada359d38f0.tar.gz
rneovim-d60ae3159ecb2906e53a44241a51dada359d38f0.tar.bz2
rneovim-d60ae3159ecb2906e53a44241a51dada359d38f0.zip
Merge pull request #1446 from splinterofchaos/obj
Allow the execution of msgpack notifications and extend vimL lightly.
Diffstat (limited to 'test/functional/api/server_requests_spec.lua')
-rw-r--r--test/functional/api/server_requests_spec.lua44
1 files changed, 42 insertions, 2 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index a37c41294b..34669c5f29 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,44 @@ 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)
+
+ it('returns an error if the request failed', function()
+ local status, err = pcall(eval, "rpcrequest(vim, 'does-not-exist')")
+ eq(false, status)
+ eq(true, string.match(err, ': (.*)') == 'Failed to evaluate expression')
+ end)
+ end)
end)