summaryrefslogtreecommitdiff
path: root/tests/fs_spec.lua
diff options
context:
space:
mode:
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)