From 046b4ed461cb78b8b302a6403cc7ea64ad6b6085 Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Tue, 17 May 2022 08:49:33 -0600 Subject: feat(fs): add vim.fs.normalize() --- test/functional/lua/fs_spec.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/functional') diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index 204bdc1567..2bcc84db0f 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -79,4 +79,23 @@ describe('vim.fs', function() ]], test_build_dir, nvim_prog_basename)) end) end) + + describe('normalize()', function() + it('works with backward slashes', function() + eq('C:/Users/jdoe', exec_lua [[ return vim.fs.normalize('C:\\Users\\jdoe') ]]) + end) + it('works with ~', function() + if iswin() then + pending([[$HOME does not exist on Windows ¯\_(ツ)_/¯]]) + end + eq(os.getenv('HOME') .. '/src/foo', exec_lua [[ return vim.fs.normalize('~/src/foo') ]]) + end) + it('works with environment variables', function() + local xdg_config_home = test_build_dir .. '/.config' + eq(xdg_config_home .. '/nvim', exec_lua([[ + vim.env.XDG_CONFIG_HOME = ... + return vim.fs.normalize('$XDG_CONFIG_HOME/nvim') + ]], xdg_config_home)) + end) + end) end) -- cgit