aboutsummaryrefslogtreecommitdiff
path: root/test/functional/core/path_spec.lua
diff options
context:
space:
mode:
authorLeonardo Mello <lsvmello@gmail.com>2023-10-09 19:08:58 -0300
committerGitHub <noreply@github.com>2023-10-10 06:08:58 +0800
commit81f67b79e8a307a45a996dbeee0213c7745aa358 (patch)
treea1c309ce8227ebe13203ad4f6b305ce8cdc0997f /test/functional/core/path_spec.lua
parent4ab2b43c8fd73e6fcbf12bdb135194c534cc4886 (diff)
downloadrneovim-81f67b79e8a307a45a996dbeee0213c7745aa358.tar.gz
rneovim-81f67b79e8a307a45a996dbeee0213c7745aa358.tar.bz2
rneovim-81f67b79e8a307a45a996dbeee0213c7745aa358.zip
fix(file_search): path with spaces in finddir() and findfile() (#25493)
Co-authored-by: dundargoc <gocdundar@gmail.com>
Diffstat (limited to 'test/functional/core/path_spec.lua')
-rw-r--r--test/functional/core/path_spec.lua41
1 files changed, 39 insertions, 2 deletions
diff --git a/test/functional/core/path_spec.lua b/test/functional/core/path_spec.lua
index 06fa13dca5..215217e771 100644
--- a/test/functional/core/path_spec.lua
+++ b/test/functional/core/path_spec.lua
@@ -1,10 +1,10 @@
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
+local command = helpers.command
local eq = helpers.eq
local eval = helpers.eval
-local command = helpers.command
-local insert = helpers.insert
local feed = helpers.feed
+local insert = helpers.insert
local is_os = helpers.is_os
local mkdir = helpers.mkdir
local rmdir = helpers.rmdir
@@ -130,3 +130,40 @@ describe('file search (gf, <cfile>)', function()
test_cfile([[\\127.0.0.1\c$\temp\test-file.txt]], [[127.0.0.1]], [[\\127.0.0.1\c$\temp\test-file.txt]])
end)
end)
+
+describe('file search with vim functions', function()
+ local test_folder = "path_spec_folder"
+
+ setup(function()
+ mkdir(test_folder)
+ end)
+
+ teardown(function()
+ rmdir(test_folder)
+ end)
+
+ ---@param option "dir" | "file"
+ local function test_find_func(option, folder, item)
+ local folder_path = join_path(test_folder, folder)
+ mkdir(folder_path)
+ local expected = join_path(folder_path, item)
+ if option == "dir" then
+ mkdir(expected)
+ else
+ write_file(expected, '')
+ end
+ eq(expected, eval('find'..option..'(fnameescape(\''..item..'\'),fnameescape(\''..folder_path..'\'))'))
+ end
+
+ it('finddir()', function()
+ test_find_func('dir', 'directory', 'folder')
+ -- test_find_func('dir', 'directory', 'folder name')
+ test_find_func('dir', 'folder name', 'directory')
+ end)
+
+ it('findfile()', function()
+ test_find_func('file', 'directory', 'file.txt')
+ -- test_find_func('file', 'directory', 'file name.txt')
+ test_find_func('file', 'folder name', 'file.txt')
+ end)
+end)