diff options
| author | William Boman <william@redwill.se> | 2021-12-25 15:11:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-25 15:11:42 +0100 |
| commit | d7e233566543d4c83199f5644f90bb116d7070f2 (patch) | |
| tree | ecfcb6e5abb937ee976eed6daac1bf2ab3bac51d /tests/path_spec.lua | |
| parent | fix: dont pass nil opts (diff) | |
| download | mason-d7e233566543d4c83199f5644f90bb116d7070f2.tar mason-d7e233566543d4c83199f5644f90bb116d7070f2.tar.gz mason-d7e233566543d4c83199f5644f90bb116d7070f2.tar.bz2 mason-d7e233566543d4c83199f5644f90bb116d7070f2.tar.lz mason-d7e233566543d4c83199f5644f90bb116d7070f2.tar.xz mason-d7e233566543d4c83199f5644f90bb116d7070f2.tar.zst mason-d7e233566543d4c83199f5644f90bb116d7070f2.zip | |
add some tests (#360)
Diffstat (limited to 'tests/path_spec.lua')
| -rw-r--r-- | tests/path_spec.lua | 23 |
1 files changed, 23 insertions, 0 deletions
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) |
