diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2018-02-13 13:45:49 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2018-02-13 20:48:51 +0100 |
commit | 6e5cb0debd23693175bd05409d3f1af4015567df (patch) | |
tree | da2298632595dc2d42c921a323ebd63978c27b82 /test | |
parent | 0f1bc5ddceb50ca8f96d91aabf8157d9758af0cd (diff) | |
download | rneovim-6e5cb0debd23693175bd05409d3f1af4015567df.tar.gz rneovim-6e5cb0debd23693175bd05409d3f1af4015567df.tar.bz2 rneovim-6e5cb0debd23693175bd05409d3f1af4015567df.zip |
ui: refactor ui options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/version_spec.lua | 16 | ||||
-rw-r--r-- | test/functional/eval/api_functions_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/eval/msgpack_functions_spec.lua | 3 | ||||
-rw-r--r-- | test/functional/ui/options_spec.lua | 33 |
4 files changed, 50 insertions, 5 deletions
diff --git a/test/functional/api/version_spec.lua b/test/functional/api/version_spec.lua index d23f058f69..7bf54c0d1e 100644 --- a/test/functional/api/version_spec.lua +++ b/test/functional/api/version_spec.lua @@ -1,6 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local mpack = require('mpack') local clear, funcs, eq = helpers.clear, helpers.funcs, helpers.eq +local call = helpers.call local function read_mpack_file(fname) local fd = io.open(fname, 'rb') @@ -18,7 +19,7 @@ describe("api_info()['version']", function() before_each(clear) it("returns API level", function() - local version = helpers.call('api_info')['version'] + local version = call('api_info')['version'] local current = version['api_level'] local compat = version['api_compatible'] eq("number", type(current)) @@ -27,7 +28,7 @@ describe("api_info()['version']", function() end) it("returns Nvim version", function() - local version = helpers.call('api_info')['version'] + local version = call('api_info')['version'] local major = version['major'] local minor = version['minor'] local patch = version['patch'] @@ -147,3 +148,14 @@ describe("api functions", function() end) end) + +describe("ui_options in metadata", function() + it('are correct', function() + -- TODO(bfredl) once a release freezes this into metadata, + -- instead check that all old options are present + local api = helpers.call('api_info') + local options = api.ui_options + eq({'rgb', 'ext_cmdline', 'ext_popupmenu', + 'ext_tabline', 'ext_wildmenu'}, options) + end) +end) diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua index fea4a87a26..6f440c7d82 100644 --- a/test/functional/eval/api_functions_spec.lua +++ b/test/functional/eval/api_functions_spec.lua @@ -106,7 +106,8 @@ describe('api functions', function() it('have metadata accessible with api_info()', function() local api_keys = eval("sort(keys(api_info()))") - eq({'error_types', 'functions', 'types', 'ui_events', 'version'}, api_keys) + eq({'error_types', 'functions', 'types', + 'ui_events', 'ui_options', 'version'}, api_keys) end) it('are highlighted by vim.vim syntax file', function() diff --git a/test/functional/eval/msgpack_functions_spec.lua b/test/functional/eval/msgpack_functions_spec.lua index 258d6ee059..a8a413f68b 100644 --- a/test/functional/eval/msgpack_functions_spec.lua +++ b/test/functional/eval/msgpack_functions_spec.lua @@ -463,7 +463,8 @@ describe('msgpackparse() function', function() eval(cmd) eval(cmd) -- do it again (try to force segfault) local api_info = eval(cmd) -- do it again - eq({'error_types', 'functions', 'types', 'ui_events', 'version'}, api_info) + eq({'error_types', 'functions', 'types', + 'ui_events', 'ui_options', 'version'}, api_info) end) it('fails when called with no arguments', function() diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index bc72ca71aa..62b08c0967 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -10,7 +10,6 @@ describe('ui receives option updates', function() before_each(function() clear() screen = Screen.new(20,5) - screen:attach() end) after_each(function() @@ -27,15 +26,21 @@ describe('ui receives option updates', function() linespace=0, showtabline=1, termguicolors=false, + ext_cmdline=false, + ext_popupmenu=false, + ext_tabline=false, + ext_wildmenu=false, } it("for defaults", function() + screen:attach() screen:expect(function() eq(defaults, screen.options) end) end) it("when setting options", function() + screen:attach() local changed = {} for k,v in pairs(defaults) do changed[k] = v @@ -76,4 +81,30 @@ describe('ui receives option updates', function() eq(defaults, screen.options) end) end) + + it('with UI extensions', function() + local changed = {} + for k,v in pairs(defaults) do + changed[k] = v + end + + screen:attach({ext_cmdline=true, ext_wildmenu=true}) + changed.ext_cmdline = true + changed.ext_wildmenu = true + screen:expect(function() + eq(changed, screen.options) + end) + + screen:set_option('ext_popupmenu', true) + changed.ext_popupmenu = true + screen:expect(function() + eq(changed, screen.options) + end) + + screen:set_option('ext_wildmenu', false) + changed.ext_wildmenu = false + screen:expect(function() + eq(changed, screen.options) + end) + end) end) |