From c65afb488eb9eab85063d79783d40ae1d7138586 Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Sun, 19 Jan 2025 13:52:31 +0100 Subject: 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 --- tests/fs_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/fs_spec.lua (limited to 'tests/fs_spec.lua') 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) -- cgit v1.2.3