diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fs_spec.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/fs_spec.lua b/tests/fs_spec.lua new file mode 100644 index 0000000..2d788c9 --- /dev/null +++ b/tests/fs_spec.lua @@ -0,0 +1,22 @@ +local fs = require("conform.fs") + +describe("fs", function() + local relative_paths = { + { "/home", "/home/file.txt", "file.txt" }, + { "/home/", "/home/file.txt", "file.txt" }, + { "/home", "/foo/file.txt", "../foo/file.txt" }, + { "/home/foo", "/home/bar/file.txt", "../bar/file.txt" }, + { "/home", "/file.txt", "../file.txt" }, + { "/home", "/home/foo/file.txt", "foo/file.txt" }, + { ".", "foo/file.txt", "foo/file.txt" }, + { "home", "home/file.txt", "file.txt" }, + { "home", "file.txt", "../file.txt" }, + } + + it("relative_path", function() + for _, paths in ipairs(relative_paths) do + local source, target, expected = unpack(paths) + assert.are.same(fs.relative_path(source, target), expected) + end + end) +end) |