From d7e233566543d4c83199f5644f90bb116d7070f2 Mon Sep 17 00:00:00 2001 From: William Boman Date: Sat, 25 Dec 2021 15:11:42 +0100 Subject: add some tests (#360) --- tests/path_spec.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/path_spec.lua (limited to 'tests/path_spec.lua') diff --git a/tests/path_spec.lua b/tests/path_spec.lua new file mode 100644 index 00000000..3ccaf3ad --- /dev/null +++ b/tests/path_spec.lua @@ -0,0 +1,23 @@ +local path = require "nvim-lsp-installer.path" + +describe("path", function() + it("concatenates paths", function() + assert.equal("foo/bar/baz/~", path.concat { "foo", "bar", "baz", "~" }) + end) + + it("concatenates paths on Windows", function() + local old_os = jit.os + jit.os = "windows" + package.loaded["nvim-lsp-installer.path"] = nil + local path = require "nvim-lsp-installer.path" + assert.equal([[foo\bar\baz\~]], path.concat { "foo", "bar", "baz", "~" }) + jit.os = old_os + end) + + it("identifies subdirectories", function() + assert.is_true(path.is_subdirectory("/foo/bar", "/foo/bar/baz")) + assert.is_true(path.is_subdirectory("/foo/bar", "/foo/bar")) + assert.is_false(path.is_subdirectory("/foo/bar", "/foo/bas/baz")) + assert.is_false(path.is_subdirectory("/foo/bar", "/foo/bars/baz")) + end) +end) -- cgit v1.2.3-70-g09d2