diff options
author | ZyX <kp-pav@yandex.ru> | 2017-01-21 00:00:47 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-03-27 00:12:22 +0300 |
commit | a3ea05c1e5965ca23b1b926c41b00597e9d0211c (patch) | |
tree | 993d5c805749a617baa15c5f931edeb95c0ec56d /test/functional/lua/api_spec.lua | |
parent | 8679feb3cbffd6b175be6a2868e980ca971125f7 (diff) | |
download | rneovim-a3ea05c1e5965ca23b1b926c41b00597e9d0211c.tar.gz rneovim-a3ea05c1e5965ca23b1b926c41b00597e9d0211c.tar.bz2 rneovim-a3ea05c1e5965ca23b1b926c41b00597e9d0211c.zip |
functests: Add some tests
Diffstat (limited to 'test/functional/lua/api_spec.lua')
-rw-r--r-- | test/functional/lua/api_spec.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua new file mode 100644 index 0000000000..6652c60adb --- /dev/null +++ b/test/functional/lua/api_spec.lua @@ -0,0 +1,36 @@ +-- Test suite for testing interactions with API bindings +local helpers = require('test.functional.helpers')(after_each) + +local funcs = helpers.funcs +local clear = helpers.clear +local NIL = helpers.NIL +local eq = helpers.eq + +before_each(clear) + +describe('luaeval(vim.api.…)', function() + describe('with channel_id and buffer handle', function() + describe('nvim_buf_get_lines', function() + it('works', function() + funcs.setline(1, {"abc", "def", "a\nb", "ttt"}) + eq({{_TYPE={}, _VAL={'a\nb'}}}, + funcs.luaeval('vim.api.nvim_buf_get_lines(1, 2, 3, false)')) + end) + end) + describe('nvim_buf_set_lines', function() + it('works', function() + funcs.setline(1, {"abc", "def", "a\nb", "ttt"}) + eq(NIL, funcs.luaeval('vim.api.nvim_buf_set_lines(1, 1, 2, false, {"b\\0a"})')) + eq({'abc', {_TYPE={}, _VAL={'b\na'}}, {_TYPE={}, _VAL={'a\nb'}}, 'ttt'}, + funcs.luaeval('vim.api.nvim_buf_get_lines(1, 0, 4, false)')) + end) + end) + end) + describe('with errors', function() + it('transforms API errors into lua errors', function() + funcs.setline(1, {"abc", "def", "a\nb", "ttt"}) + eq({false, 'string cannot contain newlines'}, + funcs.luaeval('{pcall(vim.api.nvim_buf_set_lines, 1, 1, 2, false, {"b\\na"})}')) + end) + end) +end) |