summaryrefslogtreecommitdiff
path: root/tests/fs_spec.lua
diff options
context:
space:
mode:
authorMike Vink <mike@pionative.com>2025-01-19 13:52:31 +0100
committerMike Vink <mike@pionative.com>2025-01-19 13:52:31 +0100
commitc65afb488eb9eab85063d79783d40ae1d7138586 (patch)
tree48ce8318f6fc22eb0b82df83b5c175469b853643 /tests/fs_spec.lua
Squashed 'mut/neovim/pack/plugins/start/quicker.nvim/' content from commit 049def7
git-subtree-dir: mut/neovim/pack/plugins/start/quicker.nvim git-subtree-split: 049def718213d3cdf49fdf29835aded09b3e54a3
Diffstat (limited to 'tests/fs_spec.lua')
-rw-r--r--tests/fs_spec.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/fs_spec.lua b/tests/fs_spec.lua
new file mode 100644
index 0000000..2e1e54f
--- /dev/null
+++ b/tests/fs_spec.lua
@@ -0,0 +1,20 @@
+local fs = require("quicker.fs")
+
+local home = os.getenv("HOME")
+local cwd = vim.fn.getcwd()
+
+describe("fs", function()
+ it("shortens path", function()
+ assert.equals("~/bar/baz.txt", fs.shorten_path(home .. "/bar/baz.txt"))
+ assert.equals("bar/baz.txt", fs.shorten_path(cwd .. "/bar/baz.txt"))
+ assert.equals("/foo/bar.txt", fs.shorten_path("/foo/bar.txt"))
+ end)
+
+ it("finds subpath", function()
+ assert.truthy(fs.is_subpath("/root", "/root/foo"))
+ assert.truthy(fs.is_subpath(cwd, "foo"))
+ assert.falsy(fs.is_subpath("/root", "/foo"))
+ assert.falsy(fs.is_subpath("/root", "/rooter/foo"))
+ assert.falsy(fs.is_subpath("/root", "/root/../foo"))
+ end)
+end)